18.01.2013 Views

VBScript Reference Manual for InduSoft Web Studio

VBScript Reference Manual for InduSoft Web Studio

VBScript Reference Manual for InduSoft Web Studio

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

<strong>InduSoft</strong> <strong>Web</strong> <strong>Studio</strong> <strong>VBScript</strong> <strong>Reference</strong> <strong>Manual</strong><br />

Select Case<br />

Description Executes one of several groups of statements, depending on the value of an expression<br />

Usage Select Case testexpression<br />

[Case expressionlist-n<br />

[statements-n]] . . .<br />

[Case Else<br />

[elsestatements-n]]<br />

End Select<br />

Arguments testexpression<br />

Any numeric or string expression.<br />

expressionlist-n<br />

Required if Case appears. A comma delimited list of one or more expressions.<br />

statements-n<br />

One or more statements executed if testexpression matches any part of expressionlist-.<br />

elsestatements-n<br />

One or more statements executed if testexpression doesn't match any of the Case clauses.<br />

Remarks If testexpression matches any Case expressionlist expression, the statements following that<br />

Case clause are executed up to the next Case clause, or <strong>for</strong> the last clause, up to End Select.<br />

Control then passes to the statement following End Select. If testexpression matches an<br />

expressionlist expression in more than one Case clause, only the statements following the first<br />

match are executed.<br />

The Case Else clause is used to indicate the elsestatements to be executed if no match is found<br />

between the testexpression and an expressionlist in any of the other Case selections. Although<br />

not required, it is a good idea to have a Case Else statement in your Select Case block to handle<br />

un<strong>for</strong>eseen testexpression values. If no Case expressionlist matches testexpression and there is<br />

no Case Else statement, execution continues at the statement following End Select.<br />

Select Case statements can be nested. Each nested Select Case statement must have a<br />

matching End Select statement.<br />

Example Dim Color, MyVar<br />

Sub ChangeBackground (Color)<br />

MyVar = lcase (Color)<br />

Select Case MyVar<br />

Case "red" document.bgColor = "red"<br />

Case "green" document.bgColor = "green"<br />

Case "blue" document.bgColor = "blue"<br />

Case Else MsgBox "pick another color"<br />

End Select<br />

End Sub<br />

<strong>InduSoft</strong>, Ltd. 191

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!