You are here: Keyword Reference > Keyword Table > Break

Break

Break statements provide a way to exit a While…Wend statement block.

Syntax

Break (Levels)

Parameter

Description

Levels

(Optional) The value you enter defines how many nested While…Wend statement blocks you want to terminate.If you omit this parameter, control passes to the statement following the next Wend statement encountered.

You can only include Break statements inside While…Wend statement blocks. Break statements transfer control to the statement following the Wend statement.

When used within nested While…Wend statements, you can include the Levels parameter to transfer control to the statement following the Wend level you specify.

Here are some examples. (Ellipses in the following examples represent additional statements, not shown.)

While(1)
...
While (2)
...
Break
Wend
... 
Wend

In this example, the Break statement only terminates the While…Wend which contains the statement. Control passes to the first (outside) While…Wend statement block.

Here is another example:

While(1)
...
While (2)
... 
While(3)
... 
Break(3)
Wend
... 
Wend
...
Wend

In this example, the Break(3) statement terminates all three While…Wend blocks that are active.

See also