Select Case Statement

Executes one of the statement blocks in the case based on the test variable

  1. Select Case testvar

    1. Case var1

      1. Statement Block

      Case var2

      1. Statement Block

      Case Else

      1. Statement Block

    End Select

The syntax supported by the Select statement includes the To keyword, a coma delimited list and a constant or variable.

  1. Select Case Number          ' Evaluate Number.

    1. Case 1 To 5          ' Number between 1 and 5, inclusive.

      1.  

      ' The following is the only Case clause that evaluates to True.

      Case 6, 7, 8            ' Number between 6 and 8.

      1.  

      Case 9 To 10           ' Number is 9 or 10.

      Case Else            ' Other values.

    End Select 

Related Topics: If...Then...Else

More:

Example: