求助:在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中有一个为空时就报“输入字符串的格式不正确”错!
请教该如何解决,拜谢~~~~ 展开
2个回答
展开全部
输入格式为0 主要是因为你的textbox的值为“”
判断是否为空 为空当做0处理
double t1=0, t2=0..........zk =1(这是初始值 ); //自己往后加就行
if(TextBox1.Text.Trim()!="") //Trim()去空格的
{
t1 = Convert.ToDouble(TextBox1.Text);
}
.......
double sum = (t1 + t2 + t3 + t4 + t5) * zk;
txthj.Text = sum.ToString();
判断是否为空 为空当做0处理
double t1=0, t2=0..........zk =1(这是初始值 ); //自己往后加就行
if(TextBox1.Text.Trim()!="") //Trim()去空格的
{
t1 = Convert.ToDouble(TextBox1.Text);
}
.......
double sum = (t1 + t2 + t3 + t4 + t5) * zk;
txthj.Text = sum.ToString();
展开全部
<object
codeBase=",0,29,0"
height="98" width="778" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" VIEWASTEXT>
<PARAM NAME="_cx" VALUE="19235">
<PARAM NAME="_cy" VALUE="2011">
<PARAM NAME="FlashVars" VALUE="-1">
<PARAM NAME="Movie" VALUE="1.swf">
<PARAM NAME="Src" VALUE="1.swf">
<PARAM NAME="WMode" VALUE="Transparent">
<PARAM NAME="Play" VALUE="-1">
<PARAM NAME="Loop" VALUE="-1">
<PARAM NAME="Quality" VALUE="High">
<PARAM NAME="SAlign" VALUE="">
<PARAM NAME="Menu" VALUE="0">
<PARAM NAME="Base" VALUE="">
<PARAM NAME="AllowScriptAccess" VALUE="always">
<PARAM NAME="Scale" VALUE="ShowAll">
<PARAM NAME="DeviceFont" VALUE="0">
<PARAM NAME="EmbedMovie" VALUE="0">
<PARAM NAME="BGColor" VALUE="">
<PARAM NAME="SWRemote" VALUE="">
<PARAM NAME="MovieData" VALUE="">
<PARAM NAME="SeamlessTabbing" VALUE="1">
<embed src="5xin.swf" width="214" height="76" quality="high"
pluginspage=""
type="application/x-shockwave-flash"
wmode="transparent" menu="false"> </embed>
</object>
将其中的 1.swf 换成自己的文件(完整路径)
M1
codeBase=",0,29,0"
height="98" width="778" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" VIEWASTEXT>
<PARAM NAME="_cx" VALUE="19235">
<PARAM NAME="_cy" VALUE="2011">
<PARAM NAME="FlashVars" VALUE="-1">
<PARAM NAME="Movie" VALUE="1.swf">
<PARAM NAME="Src" VALUE="1.swf">
<PARAM NAME="WMode" VALUE="Transparent">
<PARAM NAME="Play" VALUE="-1">
<PARAM NAME="Loop" VALUE="-1">
<PARAM NAME="Quality" VALUE="High">
<PARAM NAME="SAlign" VALUE="">
<PARAM NAME="Menu" VALUE="0">
<PARAM NAME="Base" VALUE="">
<PARAM NAME="AllowScriptAccess" VALUE="always">
<PARAM NAME="Scale" VALUE="ShowAll">
<PARAM NAME="DeviceFont" VALUE="0">
<PARAM NAME="EmbedMovie" VALUE="0">
<PARAM NAME="BGColor" VALUE="">
<PARAM NAME="SWRemote" VALUE="">
<PARAM NAME="MovieData" VALUE="">
<PARAM NAME="SeamlessTabbing" VALUE="1">
<embed src="5xin.swf" width="214" height="76" quality="high"
pluginspage=""
type="application/x-shockwave-flash"
wmode="transparent" menu="false"> </embed>
</object>
将其中的 1.swf 换成自己的文件(完整路径)
M1
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询