Is there any function or operator like:
If RoleName in ( "Val1", "Val2" ,"Val2" ) Then
'Go
End If
Instead of:
If RoleName = "Val1" Or RoleName = "Val2" Or RoleName = "Val2" Then
'Go
End If
Visual Basic provides the following types of operators: Arithmetic Operators perform familiar calculations on numeric values, including shifting their bit patterns. Comparison Operators compare two expressions and return a Boolean value representing the result of the comparison.
The += operator adds the value on its right to the variable or property on its left, and assigns the result to the variable or property on its left.
Try using an array and then you can use the Contains extension:
Dim s() As String = {"Val1", "Val2", "Val3"}
If s.Contains(RoleName) Then
'Go
End If
Or without the declaration line:
If New String() {"Val1", "Val2", "Val3"}.Contains(RoleName) Then
'Go
End If
From the OP, if the Contains extension is not available, you can try this:
If Array.IndexOf(New String() {"Val1", "Val2", "Val3"}, RoleName) > -1 Then
'Go
End If
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With