Possible Duplicate:
Why am I getting a FormatException was unhandled error?
I am new to C# and Stack Overflow, so if this question is inappropriate (or in the wrong place) feel free to edit or remove it.
I've made a simple calculator, but I have a problem: when I clear one of the textboxes to enter another number a message shows saying "Unhandled exception occured" with the option to quit or continue. How can I stop this message from displaying every time I clear the texboxes?
private void button1_Click(object sender, EventArgs e)
{
int value1 = Convert.ToInt32(textBox1.Text);
int value2 = Convert.ToInt32(textBox2.Text);
textBox3.Text = sum(value1, value2).ToString();
}
private void textBox1_TextChanged(object sender, EventArgs e)
{
int vlera1 = Convert.ToInt32(textBox1.Text);
}
private void textBox2_TextChanged(object sender, EventArgs e)
{
int vlera2 = Convert.ToInt32(textBox2.Text);
}
private void textBox3_TextChanged(object sender, EventArgs e)
{ }
int sum(int value1, int value2) {
return (value1) + (value2);
}