Select Case Statement
The Select Case statement is a control structure that runs one or more statements, depending on the value of an expression. It does not return a value.
Format
Select Case testexpression
Case expressionList
[statement_block]
[Case expressionList
[statement_block] ]
.
.
[Case Else
[statement_block]
End Select
The following table describes the arguments that you can use with this method.
Argument | Description |
---|---|
testexpression |
Any expression that contains a variable. |
expressionList |
One or more expressions that contain a possible value for the testexpression argument. |
statement_block |
One or more lines of code to run if the value in the testexpression argument equals a value in the expressionList argument. |
Usage
If the value in the testexpression argument is equal to the value in the expressionList argument, then Siebel VB runs the statement_block that occurs immediately after the Case clause. When Siebel VB encounters the next Case clause, the code flows to the statement that occurs immediately after the End Select statement.
The expressionList can include a list of expressions. A comma separates each expression in this list. It can include one of the following forms:
expression
expression To expression
Is comparison_operator expression
The type of each expression must be compatible with the type of the testexpression.
Each statement_block can contain any number of statements on any number of lines.
Using the Is Keyword
If you use the To keyword to specify a range of values, then the smaller value must occur first. The comparison_operator that you use with the Is keyword must contain one of the following:
< (less than)
> (greater than)
= (equal)
<= (less than or equal)
>= (greater than or equal)
<> (not equal)
If the Case is one end of a range, then you must use the Is operator. For example:
Case Is < 100