STATEMENT:  Select Case

Select Case
The Select Case conditional statement selectively executes different groups of code by comparing a variable to a Case (a series of conditions). If one of the cases (conditions) is satisfied, then the code associated with that case is executed.
You may specify multiple, comma-delimited conditions for each Case as in the first example below. If there not is a match, then the Case is skipped over and the next Case is considered, and so on for each Case.
Note that it is quite possible that none of the cases will be satisfied. Therefore, you may wish to use the optional Case Else statement. It will only execute if none of the other conditions match.
You must end the Select Case statement with End Select or you will get an error message.
Select Case finalnumber
Case 1, 5
   result = "The result is 1 or 5"
Case 2
   result = "The result is 2"
Case 3
   result = "The result is 3"
End Select


Select Case firstname
Case "Brenn"
   Welcome = "Hello Brenn"
Case "Fred"
   Welcome = "Hello Fred"
Case "Susan"
   Welcome = "Hello Susan"
Case Else
   Welcome = "Hello world"
End Select

Copyright 1999-2004 by Infinite Software Solutions, Inc. All rights reserved.
Trademark Information