我想检查 indexpage 字符串中的每个字符串。这是 indexpage
Dim indexpage As String = "string1" Or "string2"
我试过括号,OrElse,但它没有奏效......而且它不是If函数的问题。当我在没有If函数的情况下尝试它时,它仍然给我这个错误...
错误:
An unhandled exception of type 'System.InvalidCastException' occurred in Microsoft.VisualBasic.dll
Additional information: Conversion from string "string1" to type 'Boolean' is not valid.
答案 0 :(得分:1)
感谢James Thorpe,我找到了答案。
Dim testAgainst As String() = {"02","03","06","07"}
和If函数
If testAgainst.Contains(WebControl1.Source.ToString) Then
' code
Else
' code
End If