Syntax |
Select Case testexpression |
|
Description |
Used to execute a block of the Basic Control Engine statements depending on the value of a given expression. |
|
Comments |
The Select Case statement has the following parts: |
|
|
Part |
Description |
|
testexpression |
Any numeric or string expression. |
|
statement_block |
Any group of the Basic Control Engine statements. If the testexpression matches any of the expressions contained in expressionlist, then this statement block will be executed. |
|
expressionlist |
A comma separated list of expressions to be compared against testexpression using any of the following syntaxes: expression [,expression]... The resultant type of expression in expressionlist must be the same as that of testexpression. |
|
Multiple expression ranges can be used within a single Case clause. For example: Case 1 to 10,12,15 Is > 40 Only the statement_block associated with the first matching expression will be executed. If no matching statement_block is found, then the statements following the Case Else will be executed. A Select...End Select expression can also be represented with the If...Then expression. The use of the Select statement, however, may be more readable. |
|
Example |
This example uses the Select...Case statement to output the current operating system. Sub Main() |
|
See Also |
Choose (function); Switch (function); IIf (function); If...Then...Else (statement) |
S |