2013-03-01 70 views
1

我觉得这是一个非常明显的错误,但我真的无法弄清楚。看起来好像VBScript中的比较运算符不能正常工作。我正在编写一个用户输入订单金额的程序,并将此金额与1000进行比较。如果我为订单金额输入200,则程序输出200> 1000 =真。VBScript比较运算符不工作?

这里是我的程序代码:

largeOrderAmt = 1000 
orderAmt = Inputbox("What is the order amount?") 
Document.write(orderAmt & largeOrderAmt & (orderAmt > largeOrderAmt)) 

'Calculations 
If orderAmt <= largeOrderAmt then 
Document.write ("if statement called <br>") 
... 
Else 
Document.write ("else statement called <br>") 
EndIf 

这里是输出: 200 1000True称为

else语句,我真的不明白这一点。这是非常令人沮丧的。任何帮助将不胜感激,谢谢!

回答

3

,因为值作为字符串比较这就是:

"200" > "1000" = True 

将您输入到使用CIntCDbl一些,例如:

orderAmt = CDbl(Inputbox("What is the order amount?")) 
+0

非常感谢你! – Undefined 2013-03-01 17:15:07