在VB脚本中切换选择功能 [英] Switch Select function in VB Script
本文介绍了在VB脚本中切换选择功能的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
大家好朋友我在vb脚本中执行如下简单代码:
Hi friends i am executing a simple code as follows in vb script :
dim a
a=inputbox("Enter the value of a")
select case a
case (a<0)
msgbox("a is less than zero")
case (a<10)
msgbox("a is less than 10")
case (a>10 and a<20)
msgbox("a is in between 10 and 20")
case else
msgbox("a is greater than 20")
end select
为a的每个值,我得到的输出为 a大于20
你能解释我做错了吗?
for every value of a ,i am getting output as a is greater than 20
can you explain where am i doing it wrong ?
推荐答案
你不能在案件中使用比较,它们必须是价值观。 />
它可以用于此:
You cannot use comparation in cases, they must be values.
It could work for this:
dim a
repeat:
a=inputbox("Enter the value of a between 0 and 5")
if a<0 or a>5 then
msgbox("You entered an incorrect value")
goto repeat
end if
select case a
case (0)
msgbox("a is zero")
case (1)
msgbox("a is 1")
case (2)
msgbox("a is 2")
case else
msgbox("a is between 3 and 5")
end select
对于你想要做的事,你必须使用一串if if if。
For what you want to do you have to use a chain of if else if.
这篇关于在VB脚本中切换选择功能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文