Promotic

Exit - statement of language VBScript

Description:
Exits a block of Do...Loop, For...Next or the whole function..
Syntax:

Exit Do
Exit For
Exit Function

Exit Do Provides a way to exit a Do...Loop statement. It can be used only inside a Do...Loop statement. Exit Do transfers control to the statement following the Loop statement. If used within nested Do...Loop statements, then Exit Do transfers control to the loop that is one nested level above the loop where it occurs.
Exit For Provides a way to exit a For loop. It can be used only in a For...Next or For Each...Next loop. Exit For transfers control to the statement following the For...Next statement. If used within nested For...Next loops, then Exit For transfers control to the loop that is one nested level above the loop where it occurs.
Exit Function Immediately exits the procedure in which it appears.
Note:
For similar purpose in the JavaScript language is used the statement break.
Example:
VBScriptSelect and copy to clipboard

Dim iCount, MyNum
Do
For iCount = 0 To 1000
MyNum = Int(Rnd() * 100)
Select Case MyNum
Case 17
MsgBox "Case 17"
Exit For
' Exit For...Next statement
Case 29
MsgBox "Case 29"
Exit Do
' Exit Do...Loop statement
End Select
Next
Loop While iCount < 100
PROMOTIC 9.0.27 SCADA system documentation MICROSYS, spol. s r.o.

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