The Break Statement

The Break statement is a simple statement that simply jumps out of any loop. It can be used to escape from any While, For or Repeat construct.

By calling break inside a loop it stops executing the code inside the loop and continues at the point after the end of the loop.

while true

break

wend

This piece of code would loop forever if the break statement was not used.

It can also be passed a number which specifies how many loops to jump out of. This is useful for nested loops.

while true

while true

break 2

wend

wend

Note: If you attempt to break out of a loop when you aren't in one then it will cause an error.


Table of contents