VBS |案例 - 选择问题
我意识到这很愚蠢,但是我花了太多时间试图解决这个问题。我只需要这个块即可循环,直到键入“红色”,“红色”,“蓝色”或“蓝色”。 (我将脚本更改为颜色以简化可读性)。
如果有一种更好的方法来做到这一点,请详细说明。
mbb=MsgBox ("Hit No" ,4, "Start script")
If mbb=7 Then mbt=MsgBox ("Do you like Red or Blue?" ,32, "Choose color")
If mbt=1 Then SOM
Sub SOM
Do
ibb=InputBox ("Please type: Red or Blue")
Select Case ibb
Case "Red"
mbt=MsgBox ("Please explain your answer" ,32, "You chose Red")
Case "red"
mbu=MsgBox ("Please explain your answer" ,32, "You chose Red")
Case "Blue"
mbv=MsgBox ("Please explain your answer" ,32, "You chose Blue")
Case "blue"
mbw=MsgBox ("Please explain your answer" ,32, "You chose Blue")
Case Else
MsgBox "Please Type: Red or Blue"
End Select
Loop Until mbt OR mbu OR mbv OR mbw=1
End Sub
If mbt Or mbu=1 Then mbx=MsgBox ("Rouge" ,4, "Rouge")
If mbv Or mbw=1 Then mby=MsgBox ("Bleu" ,4, "Bleu")
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以在
案例
语句中列出多个拼写:这不会处理“红色”,“红色”,“红色”,“红色”和“红色”值,因此更防弹的方法是使用 lcase 或 ucase 正如Geert Bellekens所建议的那样,
strcomp 函数可以是另一种选择,可以是另一个选择。 - 不敏感,但阅读不像选定的案例块那样容易:
You can list multiple spellings in your
Case
statements:This will not handle "REd", "ReD", "reD", "rED" and "rEd" values so a more bullet-proof approach is to convert the case using LCase or UCase functions as Geert Bellekens suggests:
The StrComp function could be another option to make the comparison case-insensitive but it is not as easy to read as a Select Case block:
我设法找到答案;我意识到,在我的代码的这一部分中,避免使用案例功能会更容易。新格式如下:
I've managed to find an answer; I realized it would be easier to avoid using the case function for this part of my code. The new format is as follows: