Compiler errors 我这么困惑到底做错了什么?
我正在用BASIC做一个程序,我知道它真的很糟糕,我可以修复很多东西,但我想知道的是为什么我在结束SUB时会出错Compiler errors 我这么困惑到底做错了什么?,compiler-errors,basic,Compiler Errors,Basic,我正在用BASIC做一个程序,我知道它真的很糟糕,我可以修复很多东西,但我想知道的是为什么我在结束SUB时会出错 ' simple calculator declare sub main declare sub add declare sub subtract declare sub multiply declare sub divide declare sub question declare sub sendBack 'asks to send user back to mai
' simple calculator
declare sub main
declare sub add
declare sub subtract
declare sub multiply
declare sub divide
declare sub question
declare sub sendBack 'asks to send user back to main menu
main
sub main 'Where the user makes there selection
dim choice as integer
input "Welcome, would you like to 1.Add 2.Subtract 3.Multiply 4.Divide" ; choice
if choice = 1 then
add
elseif choice = 2 then
subtract
elseif choice = 3 then
multiply
elseif choice = 4 then
divide
else
print "Error 404 your choice does not exist, please enter a corresponding number!"
main
end sub
sub question 'Get 2 integers from user
dim num1 as integer
dim num2 as integer
input "Please enter your first number" ; num1
input "Please enter your second number" ; num 2
end sub
sub add
question
print num1 + num2
end sub
sub subtract
question
print num1 - num2
end sub
sub multiply
question
print num1 * num2
end sub
sub divide
question
print num1 / num2
end sub
sub sendBack
dim answer
input "Would you like to make another calculation, 1.Yes, 2.No" ; answer
if input = 1 then
main
elseif input = 2
sleep
else
print "Please enter a valid choice, thankyou!"
sleep
end sub
我犯的错误
你没有结束你的if陈述
IF-
ELSEIF
ELSE
END IF
在关闭SUB之前关闭IF语句。读取代码有点困难;您可能希望在将来粘贴之前将其正确缩进。:) 无论如何,您的问题在于语法。在每个ELSE语句及其相应的代码之后,如果需要,则需要结束
请参阅以更好地理解此内容。哦,很抱歉给您带来不便,我以前只使用过一次此网站,这是一个新网站,非常感谢您,没有问题。我只是想下次再把它扔出去。:)
IF-
ELSEIF
ELSE
END IF