Asp.net 为什么我不能乘0-9?利用vb和ASP
为什么我不能乘2-9个数字?例如,实际数量是=2.368,然后我试着把25和它的工作。。。当我试着把9和2相加时,它不会相乘。。有时会成倍增长,有时不会Asp.net 为什么我不能乘0-9?利用vb和ASP,asp.net,vb.net,math,double,Asp.net,Vb.net,Math,Double,为什么我不能乘2-9个数字?例如,实际数量是=2.368,然后我试着把25和它的工作。。。当我试着把9和2相加时,它不会相乘。。有时会成倍增长,有时不会 <input type="text" runat="server" value="" id="requestQuantity" /> <input id="requestCost" runat="server" readonly="true" value="" /> <input id="ActualQua
<input type="text" runat="server" value="" id="requestQuantity" />
<input id="requestCost" runat="server" readonly="true" value="" />
<input id="ActualQuantity" runat="server" readonly="true" />
<asp:Label ID="Totalcost" runat="server" BackColor="White"></asp:Label>
Dim x As Double
If ActualQuantity.Value >= requestQuantity.Value Then
x = requestCost.Value * requestQuantity.Value
Totalcost.Text = x
Else
Dim message As String = "You must not put Greater Value than Available Quantity."
Dim sb As New System.Text.StringBuilder()
sb.Append("<script type = 'text/javascript'>")
sb.Append("window.onload=function(){")
sb.Append("alert('")
sb.Append(message)
sb.Append("')};")
sb.Append("</script>")
ClientScript.RegisterClientScriptBlock(Me.GetType(), "alert", sb.ToString())
End If
将x调为双精度
如果实际数量.Value>=请求数量.Value,则
x=requestCost.Value*requestQuantity.Value
Totalcost.Text=x
其他的
Dim message As String=“您输入的值不得大于可用数量。”
将sb设置为新系统。Text.StringBuilder()
某人加上(“”)
sb.Append(“window.onload=function(){”)
某人附加(“警告('))
某人(留言)
某人附加(“)};”)
某人加上(“”)
ClientScript.RegisterClientScriptBlock(Me.GetType(),“alert”,sb.ToString())
如果结束
选项Strict On
会在这里向您显示问题,但您的问题是.Value
属性是字符串
等等
是“2.368”>=“2”
真的
为“2.368”>=“25”
假
为“2.368”>=“3”
假
为“2.368”>=“9”
假
嗯。。。实际上,对于这个例子,我认为
=
可能会产生正确的结果,但是它失败了,因为“20.368”
已经解决了问题。我只需要在请求数量上增加一倍。。谢谢你的帮助
Dim x As Double
If (reqAQ.Value) >= Convert.ToDouble(requestQuantity.Value) Then
x = Convert.ToDouble(requestCost.Value) * Convert.ToDouble(requestQuantity.Value)
Totalcost.Text = x
我看到requestCost是只读的,其值为空字符串。它总是空白的吗?如果是这样,为什么要乘以一个空白字符串?是否有其他代码正在设置requestCost或actualQuantity?该值来自我的数据库。。2.379有时2548.4…是单位成本,有时是多个实际数量=500,然后我把50。。。它起作用了。。当实际数量是10,那么我把5它不工作。。。它不会计算。。。我很困惑。。。实际数量必须大于请求数量。。我做对了。。但有时这是行不通的,我想马克·赫德会关注你的问题。
Dim x As Double
If (reqAQ.Value) >= Convert.ToDouble(requestQuantity.Value) Then
x = Convert.ToDouble(requestCost.Value) * Convert.ToDouble(requestQuantity.Value)
Totalcost.Text = x