Promotic

Select Case - statement of language VBScript

Description:
Executes one of several groups of statements, depending on the value of an expression.
Syntax:
Select Case test_expression
[Case expressionlist-n
statements-n]] ...
[Case Else expressionlist-n
elsestatements-n]]
End Select


test_expression number or text string
expressionlist-n mandatory if Case appears. Delimited list of one or more expressions.
statements-n One or more statements executed if test_expression matches any part of expressionlist-n.
elsestatements-n One or more statements executed if test_expression doesn't match any of the Case clauses.
Note:
If test_expression matches any Case expressionlist expression, then the statements following that Case clause are executed up to the next Case clause (or for the last clause, up to End Select). Control then passes to the statement following End Select. If test_expression matches an expressionlist expression in more than one Case clause, then only the statements following the first match are executed.
The Case Else statement is used to indicate the elsestatements to be executed if no match is found between the testexpression and an expressionlist in any of the other Case selections. Although not required, it is a good idea to have a Case Else statement in your Select Case block to handle unforeseen testexpression values. If no Case expressionlist matches testexpression and there is no Case Else statement, then execution continues at the statement following End Select.
Select Case statements can be nested. Each nested Select Case statement must have a matching End Select statement.

For similar purpose in the JavaScript language is used the statement switch.
See also:
Example:
VBScriptSelect and copy to clipboard

Dim Color, nVar
nVar = 1
Select Case nVar
Case 1 Color = "red"
Case 2 Color = "green"
Case 3 Color = "blue"
Case Else MsgBox "Bad color"
End Select
PROMOTIC 9.0.27 SCADA system documentation MICROSYS, spol. s r.o.

Send page remarkContact responsible person
© MICROSYS, spol. s r.o.