FOR

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

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

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$