Jump to content
Xtreme .Net Talk

aewarnick

Avatar/Signature
  • Posts

    1052
  • Joined

  • Last visited

Everything posted by aewarnick

  1. Very, Very good explanation. Thank you!!
  2. That works perfectly! How does if know to execute the loop if true or false is returned without putting: if (isNum(x.Text)==true)
  3. I said that wrong. Here is what I am really trying to do. I have a text box called x and I have a picture that the user clicks on to calculate something but if they enter in anything out of range or a character the program fails. How do I prevent it? if ((float.Parse(x.Text) >- 1)||(float.Parse(x.Text) < 9999999)) The probelm with that is if the user enters in a character it cannot convert it safely. How do I check to see if what was entered was a character or number?
  4. if (x != 1-9999999) {} How would I write that?
  5. It worked! I have another question. Does Application.Run(); only work in Main? anywhere else I put it the program just immediately shut down.
  6. static void Main() { Application.Run(); Form3 frm3=new Form3(); frm3.Show(); } Why doesn't that work? The program runs but nothing shows up.
  7. I will give it a try and be SURE to post back if it does not work. Thank you so much for your help. I know I will need it in the future. Probably near future.
  8. Please help! (if you can :D ).
  9. And second: (I cut out the Form designer part to fit it here) using System; using System.Drawing; using System.Collections; using System.ComponentModel; using System.Windows.Forms; using System.Data; namespace WindowsApplication2 { /// <summary> /// Summary description for Form1. /// </summary> public class Form1 : System.Windows.Forms.Form { private System.Windows.Forms.RichTextBox richTextBox1; private System.Windows.Forms.PictureBox pictureBox1; private System.Windows.Forms.PictureBox pictureBox2; private System.Windows.Forms.PictureBox pictureBox3; private System.Windows.Forms.PictureBox pictureBox4; private System.Windows.Forms.PictureBox pictureBox5; private System.Windows.Forms.TextBox x; /// <summary> /// Required designer variable. /// </summary> private System.ComponentModel.Container components = null; public Form1() //constructor { // // Required for Windows Form Designer support // InitializeComponent(); // // TODO: Add any constructor code after InitializeComponent call // } /// <summary> /// Clean up any resources being used. /// </summary> protected override void Dispose( bool disposing ) { if( disposing ) { if (components != null) { components.Dispose(); } } base.Dispose( disposing ); } /// <summary> /// The main entry point for the application. /// </summary> [sTAThread] static void Main() { Form3 frm3=new Form3(); frm3.Show(); Application.Run(); } private void Form1_Closed(object sender, System.EventArgs e) { Application.Exit(); } public float cube(float s){return s*s*s;} private void pictureBox1_Click(object sender, System.EventArgs e) { float side; side=float.Parse(x.Text); MessageBox.Show("Volume of cube with side: "+ side+ " is: "+ cube(side)); x.Text="YOU GOT IT!!!!"; } private void richTextBox1_TextChanged(object sender, System.EventArgs e) { } private void Form1_Load(object sender, System.EventArgs e) { } private void x_TextChanged(object sender, System.EventArgs e) { } } }
  10. Here is what I have pop up first: using System; using System.Drawing; using System.Collections; using System.ComponentModel; using System.Windows.Forms; namespace WindowsApplication2 { /// <summary> /// Summary description for Form3. /// </summary> public class Form3 : System.Windows.Forms.Form { private System.Windows.Forms.Button YES; private System.Windows.Forms.Button NO; private System.Windows.Forms.Button SureButton; /// <summary> /// Required designer variable. /// </summary> private System.ComponentModel.Container components = null; public Form3() { // // Required for Windows Form Designer support // InitializeComponent(); // // TODO: Add any constructor code after InitializeComponent call // } /// <summary> /// Clean up any resources being used. /// </summary> protected override void Dispose( bool disposing ) { if( disposing ) { if(components != null) { components.Dispose(); } } base.Dispose( disposing ); } #region Windows Form Designer generated code /// <summary> /// Required method for Designer support - do not modify /// the contents of this method with the code editor. /// </summary> private void InitializeComponent() { this.YES = new System.Windows.Forms.Button(); this.NO = new System.Windows.Forms.Button(); this.SureButton = new System.Windows.Forms.Button(); this.SuspendLayout(); // // YES // this.YES.Location = new System.Drawing.Point(24, 80); this.YES.Name = "YES"; this.YES.Size = new System.Drawing.Size(80, 40); this.YES.TabIndex = 0; this.YES.Text = "YES"; this.YES.Click += new System.EventHandler(this.YES_Click); // // NO // this.NO.DialogResult = System.Windows.Forms.DialogResult.Cancel; this.NO.ForeColor = System.Drawing.Color.Brown; this.NO.Location = new System.Drawing.Point(152, 80); this.NO.Name = "NO"; this.NO.Size = new System.Drawing.Size(80, 40); this.NO.TabIndex = 1; this.NO.Text = "NO"; this.NO.Click += new System.EventHandler(this.NO_Click); // // SureButton // this.SureButton.Font = new System.Drawing.Font("Georgia", 14.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0))); this.SureButton.ForeColor = System.Drawing.SystemColors.ActiveCaption; this.SureButton.Name = "SureButton"; this.SureButton.Size = new System.Drawing.Size(256, 56); this.SureButton.TabIndex = 2; this.SureButton.Text = "Sure you want to go through with this?"; this.SureButton.Click += new System.EventHandler(this.SureButton_Click); // // Form3 // this.AutoScaleBaseSize = new System.Drawing.Size(11, 22); this.ClientSize = new System.Drawing.Size(256, 134); this.Controls.AddRange(new System.Windows.Forms.Control[] { this.SureButton, this.NO, this.YES}); this.Font = new System.Drawing.Font("Georgia", 14.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0))); this.ForeColor = System.Drawing.Color.Red; this.Name = "Form3"; this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; this.Text = "Make Sure"; this.Load += new System.EventHandler(this.Form3_Load); this.ResumeLayout(false); } #endregion private void YES_Click(object sender, System.EventArgs e) { YES.Enabled=false; Form1 frm1 = new Form1(); frm1.Show(); this.Dispose(); } private void NO_Click(object sender, System.EventArgs e) { NO.Enabled=false; MessageBox.Show("BYE THEN", "FAREWELL"); Application.Exit(); } private void SureButton_Click(object sender, System.EventArgs e) { MessageBox.Show("Wut yu doin!!", "!!!!!!!"); int x=5, y=2; for (; x != y; ++y) MessageBox.Show("not = "+ y); MessageBox.Show(""+y); } private void Form3_Load(object sender, System.EventArgs e) { } } }
  11. Got it fixed. They did not make that easy! In the right hand pane in the Solution Explorer I had to add a project (the csproj file) to the list. Then I had to add all the forms (cs files) individually as items. Then it worked.
  12. Yes, I do have those files and they are named the same and in the same folder. Before I would just double click on the sln file and it would bring up my project visually but now the cs files aren't even there. But the cs files are in the same folder as the sln file. I tried adding the cs files to the solution explorer but I still cannot go to (as I did before) veiw, Designer and see my project.
  13. I don't have aspx even for the running correctly programs. And I mean C#.
  14. I have had many instances where I save files as or move the source files and when I do I can open only the source files and cannot veiw the designer. Is it possible to veiw the design with just the source file?
  15. Thank you.
  16. No, It works great!!!! I just like to know why things work not just how to implement them.
  17. That did it! But why? And is there another way besides: TB1.SelectAll(); TB1.Focus();
  18. TB1 is my text box name. Here is the whole thing: using System; using System.Drawing; using System.Collections; using System.ComponentModel; using System.Windows.Forms; using System.Data; namespace WindowsApplication4 { /// <summary> /// Summary description for Form1. /// </summary> public class Form1 : System.Windows.Forms.Form { private System.Windows.Forms.Button Go1; private System.Windows.Forms.Button Go2; private System.Windows.Forms.Label L1; private System.Windows.Forms.Label L2; private System.Windows.Forms.TextBox TB1; private System.Windows.Forms.TextBox TB2; /// <summary> /// Required designer variable. /// </summary> private System.ComponentModel.Container components = null; public Form1() { // // Required for Windows Form Designer support // InitializeComponent(); // // TODO: Add any constructor code after InitializeComponent call // } /// <summary> /// Clean up any resources being used. /// </summary> protected override void Dispose( bool disposing ) { if( disposing ) { if (components != null) { components.Dispose(); } } base.Dispose( disposing ); } #region Windows Form Designer generated code /// <summary> /// Required method for Designer support - do not modify /// the contents of this method with the code editor. /// </summary> private void InitializeComponent() { this.Go1 = new System.Windows.Forms.Button(); this.L1 = new System.Windows.Forms.Label(); this.L2 = new System.Windows.Forms.Label(); this.Go2 = new System.Windows.Forms.Button(); this.TB1 = new System.Windows.Forms.TextBox(); this.TB2 = new System.Windows.Forms.TextBox(); this.SuspendLayout(); // // Go1 // this.Go1.Location = new System.Drawing.Point(64, 56); this.Go1.Name = "Go1"; this.Go1.Size = new System.Drawing.Size(96, 24); this.Go1.TabIndex = 0; this.Go1.Text = "Go1"; this.Go1.Click += new System.EventHandler(this.Go1_Click); // // L1 // this.L1.BackColor = System.Drawing.Color.White; this.L1.Location = new System.Drawing.Point(13, 0); this.L1.Name = "L1"; this.L1.Size = new System.Drawing.Size(294, 48); this.L1.TabIndex = 1; this.L1.Text = "L1"; this.L1.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; // // L2 // this.L2.BackColor = System.Drawing.Color.White; this.L2.Location = new System.Drawing.Point(16, 88); this.L2.Name = "L2"; this.L2.Size = new System.Drawing.Size(288, 56); this.L2.TabIndex = 2; this.L2.Text = "L2"; this.L2.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; // // Go2 // this.Go2.Location = new System.Drawing.Point(160, 56); this.Go2.Name = "Go2"; this.Go2.Size = new System.Drawing.Size(96, 24); this.Go2.TabIndex = 3; this.Go2.Text = "Go2"; this.Go2.Click += new System.EventHandler(this.Go2_Click); // // TB1 // this.TB1.Location = new System.Drawing.Point(0, 56); this.TB1.Name = "TB1"; this.TB1.Size = new System.Drawing.Size(56, 20); this.TB1.TabIndex = 4; this.TB1.Text = "textBox1"; this.TB1.TextAlign = System.Windows.Forms.HorizontalAlignment.Center; // // TB2 // this.TB2.Location = new System.Drawing.Point(264, 56); this.TB2.Name = "TB2"; this.TB2.Size = new System.Drawing.Size(56, 20); this.TB2.TabIndex = 5; this.TB2.Text = "textBox2"; this.TB2.TextAlign = System.Windows.Forms.HorizontalAlignment.Center; // // Form1 // this.AutoScaleBaseSize = new System.Drawing.Size(5, 13); this.BackColor = System.Drawing.SystemColors.ControlLight; this.ClientSize = new System.Drawing.Size(320, 142); this.Controls.AddRange(new System.Windows.Forms.Control[] { this.TB2, this.TB1, this.Go2, this.L2, this.L1, this.Go1}); this.Name = "Form1"; this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; this.Text = "Form1"; this.Load += new System.EventHandler(this.Form1_Load); this.ResumeLayout(false); } #endregion /// <summary> /// The main entry point for the application. /// </summary> [sTAThread] static void Main() { Application.Run(new Form1()); } private void Form1_Load(object sender, System.EventArgs e) { } int ac=0, bc=0, cc=0; private void Go1_Click(object sender, System.EventArgs e) { L1.Text=""; L2.Text=""; if(TB1.Text == "a"||TB1.Text == "b"||TB1.Text == "c") { char letter = char.Parse(TB1.Text); switch (letter) { case 'a': ++ac; L1.Text+="a: "+ ac; break; case 'b': ++bc; L1.Text+="b: "+ bc; break; case 'c': ++cc; L1.Text+="c: "+ cc; break; } } else { MessageBox.Show("Incorrect letter entered. Lowercase letters only"); Cursor.Position = new System.Drawing.Point(493,430);} } public void count(int a, int b, int c) { L1.Text+="Totals for each letter:"; L2.Text+="a: "+ a+ "\nb: "+ b+ "\nc: "+ c; } private void Go2_Click(object sender, System.EventArgs e) { TB1.SelectAll(); L1.Text=""; L2.Text=""; count(ac, bc, cc); } } }
  19. Do I need to put it in a certain place. It is not working. private void Go2_Click(object sender, System.EventArgs e) { TB1.SelectAll(); L1.Text=""; L2.Text=""; count(ac, bc, cc); }
  20. I could not figure out how to use it. I tried what I thought would work: TextBox.SelectAll (TB1);
  21. What I mean is highlighting for example all the words in a text box each time the user presses a button to make it easy to continuously enter in different text.
  22. In a form, how would I go about putting the curser either on a certain button or in a box with everything highlighted?
  23. I could not figure out that weird thing either! Download this: http://www.powerarchiver.com/download/ It is very easy to use and install. I love it! You just right click on the file and extract it.
  24. If you have win9x it is in: C:\Windows\Command\Extract.exe Hold in Shift and right click on the cab file Go to open with and find the Extract program.
  25. I could not upload it here. It went to a blank screen and stayed there every time. I uploaded it to my web site. Download it here: It is called C Sharp project.
×
×
  • Create New...