0
基本上我試圖做一個.vbs文件,給你十個隨機加法問題。然後,在輸入框中輸入給定問題的答案。除了If
/Else
陳述之外,一切都可以正常工作,告訴你自己是對還是錯。如果它說「什麼是2 + 2」,而我輸入「4」(不含引號),那麼它會輸出「(你攻擊)TRIP!POW!哎呦錯誤如果你鍵入:下面的代碼:檢查是否(數字)加上(數字)等於你輸入的答案
msgbox("Starting addition. Press OK to begin.")
dim i
i = 0
Do
i = i + 1
'i is for the question timer
Dim max,min
max=100 'max random
min=1 'min random
dim j, k, l 'part part total
Randomize
msgbox("What is")
j = Int((max-min+1)*Rnd+min)
msgbox(j)
msgbox("plus")
k = Int((max-min+1)*Rnd+min)
msgbox(k)
answer = Inputbox("I hope you got all of that... ^_^")
l = j + k
if answer = l then
msgbox("(You attack) BAM! Right on target")
else
msgbox("(You attack) TRIP! POW! ouchy wrong")
msgbox("You could've gotten it right IF you typed:")
msgbox(l)
end if
loop until i = 10
歡迎來到[so]。請添加更多令人滿意的代碼[如何創建最小,完整和可驗證的示例](http://stackoverflow.com/help/mcve) – JosefZ
好吧,我編輯它以顯示我的整個程序。謝謝! – oBSERVEr