Select Case (switch) in Visual Basic
VB also provides a Select Case block that you can use to evaluate a single variable or expression for multiple possible values. The Select Case statement supports the String, Char, Date, and Boolean data types, as well as virtually every simple numeric data type.
In the following code, each case examines the MyNumber variable and tests whether it’s equal to a specific integer.
Example
Module Module1 Sub Main() Dim Number1 As Integer Number1 = 2 Select Case Number1 Case 1 Console.WriteLine("value is 1") Case 2 Console.WriteLine("value is 2") Case Else Console.WriteLine("value is other than 1 and 2") End Select Console.ReadLine() End Sub End Module
Output
value is 2