求助:在ASP.NET C# 中计算合计金额(小计+小计+小计+小计)*折扣=总金额) 如图:
我写的后台代码:protectedvoidButton1_Click(objectsender,EventArgse){doublet1=Convert.ToDouble...
我写的后台代码:
protected void Button1_Click(object sender, EventArgs e)
{
double t1 = Convert.ToDouble(TextBox1.Text);
double t2 = Convert.ToDouble(TextBox2.Text);
double t3 = Convert.ToDouble(TextBox3.Text);
double t4 = Convert.ToDouble(TextBox4.Text);
double t5 = Convert.ToDouble(TextBox5.Text);
double zk = Convert.ToDouble(txtzk.Text) * 0.1;
double sum = (t1 + t2 + t3 + t4 + t5) * zk;
txthj.Text = sum.ToString();
}
当textbox1~textbox5中有一个为空时就报“输入字符串的格式不正确”错!
请教该如何解决,拜谢~~~~ 展开
protected void Button1_Click(object sender, EventArgs e)
{
double t1 = Convert.ToDouble(TextBox1.Text);
double t2 = Convert.ToDouble(TextBox2.Text);
double t3 = Convert.ToDouble(TextBox3.Text);
double t4 = Convert.ToDouble(TextBox4.Text);
double t5 = Convert.ToDouble(TextBox5.Text);
double zk = Convert.ToDouble(txtzk.Text) * 0.1;
double sum = (t1 + t2 + t3 + t4 + t5) * zk;
txthj.Text = sum.ToString();
}
当textbox1~textbox5中有一个为空时就报“输入字符串的格式不正确”错!
请教该如何解决,拜谢~~~~ 展开
若以下回答无法解决问题,邀请你更新回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询