我想计算 1 个文本框中五个文本框的总和.... 但是,当我在五个文本框中留空一个文本框时,它会给出错误输入字符串格式不正确 下面是我的代码
if (textBox6.Text.Length == 0)
// textBox12.Text = (Convert.ToInt32(textBox5.Text) - Convert.ToInt32(textBox11.Text)).ToString();
{
textBox11.Text = (Convert.ToInt32(textBox7.Text) + Convert.ToInt32(textBox8.Text) + Convert.ToInt32(textBox9.Text) + Convert.ToInt32(textBox10.Text)).ToString();
textBox12.Text = (Convert.ToInt32(textBox5.Text) - Convert.ToInt32(textBox11.Text)).ToString();
}
else if (textBox7.Text.Length == 0)
{
//textBox11.Text = (Convert.ToInt32(textBox6.Text) + Convert.ToInt32(textBox7.Text) + Convert.ToInt32(textBox8.Text) + Convert.ToInt32(textBox9.Text) + Convert.ToInt32(textBox10.Text)).ToString();
textBox11.Text = (Convert.ToInt32(textBox6.Text) + Convert.ToInt32(textBox8.Text) + Convert.ToInt32(textBox9.Text) + Convert.ToInt32(textBox10.Text)).ToString();
textBox12.Text = (Convert.ToInt32(textBox5.Text) - Convert.ToInt32(textBox11.Text)).ToString();
}
else if (textBox8.Text.Length == 0)
{
//textBox11.Text = (Convert.ToInt32(textBox6.Text) + Convert.ToInt32(textBox7.Text) + Convert.ToInt32(textBox8.Text) + Convert.ToInt32(textBox9.Text) + Convert.ToInt32(textBox10.Text)).ToString();
textBox11.Text = (Convert.ToInt32(textBox6.Text) + Convert.ToInt32(textBox7.Text) + Convert.ToInt32(textBox9.Text) + Convert.ToInt32(textBox10.Text)).ToString();
textBox12.Text = (Convert.ToInt32(textBox5.Text) - Convert.ToInt32(textBox11.Text)).ToString();
}
else if (textBox9.Text.Length == 0)
{
//textBox11.Text = (Convert.ToInt32(textBox6.Text) + Convert.ToInt32(textBox7.Text) + Convert.ToInt32(textBox8.Text) + Convert.ToInt32(textBox9.Text) + Convert.ToInt32(textBox10.Text)).ToString();
textBox11.Text = (Convert.ToInt32(textBox6.Text) + Convert.ToInt32(textBox7.Text) + Convert.ToInt32(textBox8.Text) + Convert.ToInt32(textBox10.Text)).ToString();
textBox12.Text = (Convert.ToInt32(textBox5.Text) - Convert.ToInt32(textBox11.Text)).ToString();
}
else if (textBox10.Text.Length == 0)
{
//textBox11.Text = (Convert.ToInt32(textBox6.Text) + Convert.ToInt32(textBox7.Text) + Convert.ToInt32(textBox8.Text) + Convert.ToInt32(textBox9.Text) + Convert.ToInt32(textBox10.Text)).ToString();
textBox11.Text = (Convert.ToInt32(textBox6.Text) + Convert.ToInt32(textBox7.Text) + Convert.ToInt32(textBox8.Text) + Convert.ToInt32(textBox9.Text)).ToString();
textBox12.Text = (Convert.ToInt32(textBox5.Text) - Convert.ToInt32(textBox11.Text)).ToString();
}
else
textBox11.Text = (Convert.ToInt32(textBox6.Text) + Convert.ToInt32(textBox7.Text) + Convert.ToInt32(textBox8.Text) + Convert.ToInt32(textBox9.Text) + Convert.ToInt32(textBox10.Text)).ToString();
textBox12.Text = (Convert.ToInt32(textBox5.Text) - Convert.ToInt32(textBox11.Text)).ToString();
// (Convert.ToInt32(textBox6.Text) +
}