首页 > 解决方案 > VBScript 错误 800A0401 - 预期语句

问题描述

为什么 WSH 在我的代码上抛出一个错误,说有一个

第 1 行字符 1 中的“预期语句”。

这是我的代码:

type = inputbox("What would you like to calculate with? (m = muliplication, d = division, a = addition, s = subtraction)")
if type = not "m" or "s" or "a" or "d" or "M" or "S" or "A" or "D" then
a=msgbox("You did not select one of the options.")
elseif type = "m" or "M" then
input1 = inputbox("You chose multiplication. What is the first number of your math sentence?")
input2 = inputbox("What is the other number of your math sentence?")
output = input1 * input2
display = msgbox("The answer to " & input1 & " " & chrw(0215) & " " & input2 & " is " & output & ".")
elseif type = "d" or "D" then
input1 = inputbox("You chose division. What is the dividend of your math sentence?")
input2 = inputbox("What is the divisor of your math sentence?")
output = input1 \ input2
display = msgbox("The answer to " & input1 & " " & chrw(247) & " " & input2 & " is " & output & ".")
elseif type = "a" or "A" then
input1 = inputbox("You chose addition. What is the first number of your math sentence?")
input2 = inputbox("What is the other number of your math sentence?")
output = input1 + input2
display = msgbox("The answer to " & input1 & " + " & input2 & " is " & output & ".")
elseif type = "s" or "S" then
input1 = inputbox("You chose subtraction. What is the first number of your math sentence?")
input2 = inputbox("What is the other number of your math sentence?")
output = input1 - input2
display = msgbox("The answer to " & input1 & " - " & input2 & " is " & output & ".")
end if

我知道这很明显,但我在第 1 行 char 1 上看不到任何错误。

请向我解释如何解决这个问题。

标签: vbscript

解决方案


您不能在 VBScript 中使用“类型”一词作为变量名。

提示:使用提供语法高亮的编辑器,例如 Notepad3、Notepad++、UltraEdit、VS Code、VBSEdit 等。“type”是保留字等问题立即显而易见:

在此处输入图像描述


推荐阅读