# FOR

FOR Variable = Expression TO Expression [ STEP Expression ] ... NEXT

Repeats a loop while incrementing a variable. Note that the variable must be :

- Numeric, i.e. a byte, a short, an integer or a floating point number.
- A local variable.

Note that if the initial Expression is higher than the 'to' Expression (for positive STEP values), or if the initial Expression is less than the 'to' Expression (for negative ones) the loop will not be executed at all.

Example

    DIM I AS Integer

    FOR I = 1 TO 20 STEP 3
      PRINT I & " ";
    NEXT

    1 4 7 10 13 16 19

See also

BREAK, CONTINUE, DO, FOR EACH, LOOP, REPEAT, UNTIL, WHILE, WITH

Previous: FOR EACH Next: Format$