Name
Select Case Statement
Synopsis
Select Casetestexpression
[Caseexpressionlist-n
[statements-n
]] ... [Case Else [elsestatements
]] End Select
testexpression
required; anyAny numeric or string expression whose value determines which block of code is executed.
expressionlist-n
required; anyComma-delimited list of expressions to compare values with
testexpression
statements-n
optionalProgram statements to execute if a match is found between any section of
expressionlist
andtestexpression
elsestatements
optionalProgram statements to execute if a match between
testexpression
and anyexpressionlist
cannot be found
expressionlist
can use any (or a
combination of any) of the following:
expressionlist syntax |
Examples |
|
iVar - iAnotherVar iVar |
|
5 To 10 8 To 11, 13 to 15 "A" To "D" |
Is |
Is = 10 |
Description
Allows for conditional execution of a block of code, typically out of
three or more code blocks, based on some condition. Use the
Select
Case
statement as an
alternative to complex nested If...Then...Else
statements.
Get VB.NET Language Pocket Reference now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.