I have seen many hits on my blog with similar search terms and also the question being asked in various forums. The answer is really very simple.
Consider the following block in SQL:
IF TestValue IN (Value1, Value2, Value3, Value4, Value5)
BEGIN
-- do something here
END
The VB.NET equivalent of the above would be:
Select Case TestValue
Case Value1, Value2, Value3, Value4, Value5
' do something here
End Select
And the negated version isn’t any difficult either.
SQL Version:
IF TestValue NOT IN (Value1, Value2, Value3, Value4, Value5)
BEGIN
-- do something here
END
VB.NET Version:
Select Case TestValue
Case Value1, Value2, Value3, Value4, Value5
Case Else
' do something here
End Select
There could be many other ways to do this. But I find this one a lot more handy and also easy to read.
Enjoy!![]()

April 28, 2012 at 3:47 pm
Excellent issues altogether, you just received a new reader. What might you suggest about your put up that you made some days in the past? Any certain?
July 19, 2013 at 2:10 pm
VB.NET equivalent of the above would be:
dim myList Integer() = new Integer() {Value1, Value2, Value3, Value4, Value5 }
if myList.contains( TestValue ) Then …