Select 案例是否部分运行?
下面是一个函数,它是较长脚本的一部分。当我运行代码时,会弹出Select 案例是否部分运行?,select,vbscript,Select,Vbscript,下面是一个函数,它是较长脚本的一部分。当我运行代码时,会弹出Case Else分支的消息框(尽管输入是有效的运算符),但不会退出脚本 当运算符有效时,为什么代码跳转到Case Else?当脚本已经在Case Else分支中时,它为什么不终止呢 Function opr_math(opr, first, second) Select Case opr Case "+" total = CInt(first) + CInt(second)
Case Else
分支的消息框(尽管输入是有效的运算符),但不会退出脚本
当运算符有效时,为什么代码跳转到Case Else
?当脚本已经在Case Else
分支中时,它为什么不终止呢
Function opr_math(opr, first, second)
Select Case opr
Case "+"
total = CInt(first) + CInt(second)
MsgBox "Your sum: " & total, 0+65, "Sum"
Case "*"
total = CInt(first) * CInt(second)
MsgBox "Your product: " & total, 0+65, "Product"
Case "-"
total = CInt(first) - CInt(second)
MsgBox "Your difference: " & total, 0+65, "Difference"
Case "/"
total = CInt(first) / CInt(second)
MsgBox "Your quotient: " & total, 0+65, "Quotient"
Case "^"
total = CInt(first) ^ CInt(second)
MsgBox "Your exponent product: " & total, 0+65, "Exponential Product"
Case "fix"
total = Fix(CInt(first))
MsgBox "Fixed number of " & first & " is: " & total, 0+65, "Fixed Number"
Case "abs"
total = Abs(CInt(first))
MsgBox "Absolute of " & first & " is: " & total, 0+65, "Absolute Number"
Case Else
MsgBox "Your operator was either not listed or invalid!", 0+16, "Error!"
main.Run("C:\Users\JunFan\Desktop\opr.txt")
WScript.Quit
End Select
End Function
顺便说一下,第一行代码不应该缩进!哦,是的!现在我知道了!已经是第二次了!其他案例没有部分运行!我只是有很多错误消息框,我找不到哪一个是它!我应该读清楚的!区分大小写?尝试
选择case LCase(opr)
。去掉main.Run()行,看看它是否退出。。。