Exit: Difference between revisions
Jump to navigation
Jump to search
Created page with "EXIT DO EXIT FOR EXIT FUNCTION EXIT SUB '''Description''' EXIT terminates the execution of a block of code in a DO...LOOP, FOR...NEXT, FOR EACH...NEXT, FUNCTION, or SUB. ..." |
No edit summary |
||
Line 1: | Line 1: | ||
EXIT | EXIT Do | ||
EXIT | EXIT For | ||
EXIT | EXIT Function | ||
EXIT | EXIT Sub | ||
== Description == | |||
EXIT terminates the execution of a block of code in a | EXIT terminates the execution of a block of code in a Do...Loop, For...Next, For Each...Next, Function, or Sub. When used to exit a loop, either Do...Loop, For...Next, or For Each...Next, execution continues with the first statement after the loop; if the loop is nested inside another loop, control is transferred to the loop outside the loop where the EXIT is encountered. When used to exit a Function or Sub procedure, execution continues with the first statement after the statement which called the procedure. | ||
== Example == | |||
<pre> | <pre> | ||
REM EXIT Example | REM EXIT Example | ||
'EXIT terminates loops and procedures | 'EXIT terminates loops and procedures | ||
Dim i | |||
For i = 1 to 10 | |||
If i > 1 Then | |||
EXIT | EXIT For | ||
END | END If | ||
PRINT "Attempting to do nothing" | PRINT "Attempting to do nothing" | ||
DoNothing | DoNothing | ||
Next | |||
PRINT "Done" | PRINT "Done" | ||
Sub DoNothing | |||
EXIT | EXIT Sub | ||
PRINT "This statement is never executed" | PRINT "This statement is never executed" | ||
End Sub | |||
</pre> | </pre> | ||
== Output == | |||
<pre> | <pre> | ||
Line 38: | Line 38: | ||
</pre> | </pre> | ||
== Related Items == | |||
[[for...next|FOR...NEXT]], [[do...loop|DO...LOOP]], [[function|FUNCTION]], [[property|PROPERTY]], [[sub|SUB]] | [[for...next|FOR...NEXT]], [[do...loop|DO...LOOP]], [[function|FUNCTION]], [[property|PROPERTY]], [[sub|SUB]] | ||
[[Category:Language Reference]] |
Revision as of 21:18, 8 August 2012
EXIT Do
EXIT For
EXIT Function
EXIT Sub
Description
EXIT terminates the execution of a block of code in a Do...Loop, For...Next, For Each...Next, Function, or Sub. When used to exit a loop, either Do...Loop, For...Next, or For Each...Next, execution continues with the first statement after the loop; if the loop is nested inside another loop, control is transferred to the loop outside the loop where the EXIT is encountered. When used to exit a Function or Sub procedure, execution continues with the first statement after the statement which called the procedure.
Example
REM EXIT Example 'EXIT terminates loops and procedures Dim i For i = 1 to 10 If i > 1 Then EXIT For END If PRINT "Attempting to do nothing" DoNothing Next PRINT "Done" Sub DoNothing EXIT Sub PRINT "This statement is never executed" End Sub
Output
Atempting to do nothing Done