我试图在VBScript中制作一个计算器来测试我的技能,但遇到了一个错误。我的程序使用多个if语句来测试用户输入的内容。使用多个else语句
这里是我下面的代码:
Dim head
Dim msg1, msgErr, msgAns
Dim input1, num1, num2
Dim ans
head = "Calculator"
msg1 = msgBox("Ruan's Vbscript calculator",0,head)
input1 = inputBox("How do you want to calculate? You can type (+ - * /)",head)
num1 = inputBox("Enter your first number",head)
num2 = inputBox("Enter your second number",head)
if (input1 = vbcancel) then
wscript.quit()
else if (input1 = "+") then
ans = num1 + num2
else if (input1 = "-") then
ans = num1 - num2
else if (input1 = "*") then
ans = num1 * num2
else if (input1 = "/") then
ans = num1/num2
else
msgErr = msgBox("Make sure you type '+' or '-' or '*' or '/' with no extra letter or spaces","Error")
end if
msgAns = msgBox "Your answere is: " + head
当我运行该程序,错误说:“预期语句的结束”。我没有看到这里的问题,因为我有end if
所有这些else if
声明。
我相信VBScript中的正确的语法是'ElseIf' http://www.w3schools.com/vbscript/vbscript_conditionals.asp –
'输入1 = vbcancel'不会因为有些人可能认为工作。 –
任何愿意解释为什么一个计算器声称5 + 7是57的计算器值得分吗? –