sum of textbox values

Apr 13 2011 2:39 AM

  hai,

 to find the sum of textbox values ,i use this code

private void textBox10_TextChanged(object sender, EventArgs e)

        {

           int n1, n2, n3, n4, n5,sum;

            n1 = Convert.ToInt32(textBox6.Text.ToString());

            n2 = Convert.ToInt32(textBox7.Text.ToString());

            n3 = Convert.ToInt32(textBox8.Text.ToString());

            n4 = Convert.ToInt32(textBox9.Text.ToString());

            n5 = Convert.ToInt32(textBox10.Text.ToString());

            sum = n1 + n2 + n3 + n4 + n5;

            // sum

            textBox16.Text = Convert.ToString(sum);

        }

 but the "Input string was not in a correct format." this message is displayed.




Answers (5)