Community QBasic

Rebooting the QBasic we all know and love!


Project maintained by Cory Smith

EXIT Statements

Exit a DO, FOR, FUNCTION or SUB.

Syntax

EXIT DEF

EXIT DO

EXIT FOR

EXIT FUNCTION

EXIT SUB

Comments

For DO and FOR loops, execution continues at the first statement following the loop.

For FUNCTION and SUB, execution continues at the statement following the statement that called the function or subroutine.

Examples

j = 30
FOR i = 1 TO 50
  IF i = j THEN
    EXIT FOR
  END IF
NEXT i
PRINT "Ending value is"; i

Resulting in…

Ending value is 30

See Also