1

これは本当に明白なバグだと思いますが、本当に理解できません。VBScript の比較演算子が正しく機能していないようです。ユーザーが注文金額を入力し、この金額を 1000 と比較するプログラムを作成しています。注文金額に 200 を入力すると、プログラムは 200 > 1000 = true を出力します。

私のプログラムのコードは次のとおりです。

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 statement called

私は本当にそれを取得しません。これは非常にイライラします。どんな助けでも大歓迎です、ありがとう!

4

1 に答える 1

3

これは、値が文字列として比較されるためです。

"200" > "1000" = True

CIntまたはを使用して入力を数値に変換しますCDbl。例:

orderAmt = CDbl(Inputbox("What is the order amount?"))
于 2013-03-01T17:09:14.743 に答える