Reputation: 483
This should be the easiest question all day!
All I want to see is how to condense some code.
Example:
If textbox.text = "0000" then
'do something
End If
If textbox.text = "0001" then
'do something
End If
What I want to do, is have that in 1 statement.
Upvotes: 0
Views: 705
Reputation: 4742
If you want each condition to do something different:
If testbox.text = "0000" Then Do.Something Else If testbox.text = "0001" Then Do.SomethingDifferent
If you have multiple conditions to test to do the same thing:
If testbox.text = "0000" OR testbox.text = "0001" OR testbox.text = "0002" Then Do.Something
Upvotes: 2
Reputation: 9024
You can use the .Contains
from an array of data. Here is a simple example.
Dim choices = {"0000","0001","0002"}
If choices.Contains(textbox.text) Then
'do something
End If
Upvotes: 5