繁体   English   中英

如果textbox.text = more,则为1个选项

[英]If textbox.text = more then 1 option

这应该是整天最简单的问题!

我只想看一下如何压缩一些代码。

例:

If textbox.text = "0000" then
'do something
End If

If textbox.text = "0001" then
    'do something
    End If

我想做的是在1条陈述中说明。

您可以从数据数组中使用.Contains 这是一个简单的例子。

Dim choices = {"0000","0001","0002"}  
If choices.Contains(textbox.text) Then
  'do something
End If

如果您希望每个条件都做不同的事情:

If testbox.text = "0000" Then Do.Something Else If testbox.text = "0001" Then Do.SomethingDifferent

如果您有多个条件要测试以做同一件事:

If testbox.text = "0000" OR testbox.text = "0001" OR testbox.text = "0002" Then Do.Something

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM