我要做的是检查一个值是否与两个数字之一匹配(并且很容易添加到要比较的数字中)。而不是做一个冗长的方式,例如:
If Number = 1 Or Number = 2 Then ...
我正在尝试做这样的事情:
If Number In (1,2) Then...
由于该In
运算符在 VB 中不可用,因此我尝试了以下代码:
Protected SectionID As Integer = HttpContext.Current.Request.QueryString("sectionid")
Protected PageID As Integer = HttpContext.Current.Request.QueryString("pageid")
Protected Sub HotspotsLV_ItemDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.ListViewItemEventArgs) Handles HotspotsLV.ItemDataBound
Dim SecondLineHolder As HtmlControl = e.Item.FindControl("SecondLineHolder")
Select Case True
Case New String("2", "3").Contains(SectionID) : SecondLineHolder.Attributes("style") = "color:#21720B"
Case New String("8", "12").Contains(PageID) : SecondLineHolder.Attributes("style") = "color:#1B45C2"
End Select
End Sub
我发现这仅在SectionID
2 或PageID
8 时有效。如果SectionID
是 3 或PageID
12,则它不起作用。为什么会这样,我能做些什么来解决这个问题?谢谢。