Do … Loop-While

Do
    [statement(s)]
    [Exit Do]
    [statement(s)]
Loop While condition

Executes a series of statements as long as a given condition is not zero (True)

Where:

  • Loop-block begins with Do and ends with Loop While <condition> statement.
  • Do...Loop While loops can be nested to any level.
  • Each Loop-While matches the most recent Do.


The Do-Loop-While loop statement syntax has these parts: 
  • condition : Numeric expression or string expression that evaluates to True or False. 
  • statements : Optional. One or more statements executed while condition is True. 
  • Exit Do: Optional. Transfers control out of the Do-Loop-While block.


Example:

i%=0

Do
    Print i%
    i%=i%+1
Loop While i%<3

Output:


0
1
2

Comments