qbasic.hlp (Topic list)
Important Notice
The pages on this site contain documentation for very old MS-DOS software, purely for historical purposes. If you're looking for up-to-date documentation, particularly for programming, you should not rely on the information found here, as it will be woefully out of date.
FOR...NEXT Statement
  Contents  Index  Back
──────────────────────────────────────────────────────────────────────────────
Repeats a block of statements a specified number of times.
 
FOR counter = start TO end [STEP increment]
    [statementblock]
NEXT [counter [,counter]...]
 
    ■ counter          A numeric variable used as the loop counter.
    ■ start and end    The initial and final values of the counter.
    ■ increment        The amount the counter is changed each time through
                       the loop.
 
Example:
    FOR i% = 1 TO 15
        PRINT i%
    NEXT i%
    FOR i% = 7 to -6 STEP -3
        PRINT i%
    NEXT i%
 
See Also    DO...LOOP    EXIT    WHILE...WEND