Tuesday, July 28, 2009

What is wrong with this C# code?

I'm tryin to get the input from textbox1, and output it to textbox2. With the current code I get "FormatException was unhandled.Input string was not in a correct format." Also, I am looking to make a timer how would I incorporate the input from textbox1 to the timer?





private void button1_Click(object sender, EventArgs e)


{


int timer1 = 0;


int chk1,chk2;


string text2Display = Convert.ToString(timer1);


if (checkBox1.Checked)


chk1 = 1;


else chk1 = 0;





if (checkBox2.Checked)


chk2 = 1;


else chk2 = 0;





if (chk1+chk2 == 2)


Text = "AutoRelogger [Dual Accounts]";





if (chk1 + chk2 == 1)


Text = "AutoRelogger[One Account]";





timer1 = Convert.ToInt32(textBox1.Text);


text2.Text = textBox1.Text;





}

What is wrong with this C# code?
likely the problem is in this line





timer1 = Convert.ToInt32(textBox1.Text);





so encapulate in try{}catch(){} and go from there
Reply:Why do not you contact a C# expert. Check http://k.aplis.net/


No comments:

Post a Comment