7.1.11 Exit xx
- Purpose
-
Flow control statement for exiting from a While...End loop, For...Next loop, For...End For loop, Do...Loop loop, Function procedure, or Sub procedure.
- Syntax
Exit While Exit For Exit Do Exit Function Exit Sub
- Description
-
The purpose of each Exit statement is as follows.
- Exit While
-
Exits from a While...End loop and passes control to the statement following the End statement. You can use Exit While only within a While...End statement. When used within nested While...End statements, Exit While transfers control to the next loop outside the loop in which it appears.
- Exit For
-
Exits from a For...Next loop and passes control to the statement following the Next statement. You can use Exit For only within a For...Next or For...End For loop. When used within nested For...Next or For...End For loops, Exit For transfers control to the next loop outside the loop in which it appears.
- Exit Do (from version 05-10)
-
Exits from a Do...Loop statement and passes control to the statement following the Loop statement. You can use Exit Do only within a Do...Loop statement. When used within nested Do...Loop statements, Exit Do transfers control to the next loop outside the loop in which it appears.
- Exit Function
-
Immediately exits from the Function procedure in which it appears. Control moves to the statement following the statement that called the Function procedure.
- Exit Sub
-
Immediately exits from the Sub procedure in which it appears. Control moves to the statement following the statement that called the Sub procedure.
- JP1/Script version
-
Supported from JP1/Script 01-00.