How to use Select Case function to evaluate different conditions in VB.NET

If you have to select one of the options from various possibilities then your best option is to use the case

In VB.NET you would used something like below.

Select [ Case ] testexpression
[ Case expressionlist
[ statements ] ]
[ Case Else
[ elsestatements ] ]
End Select

Here is more practical example:

Dim intMyNumber as Integer = 20
Select Case intMyNumber
Case 1
Debug.WriteLine("The value of my number is 1")

Case 2,3,4
Debug.WriteLine("The value of my number is between 2 and 4.")

Case 5 to 9
Debug.WriteLine("The value of my number is between 5 and 9")

Case Else
Debug.WriteLine("The value of my number is not in 1 to 9")

End Select