fr de es it nl pl pt pt_BR mk sq ca ar fa vi ja ru zh zh_TW eo
Home > lang > for
 
Previous  Next  Edit  Rename  Undo  Refresh  Search  Administration   
Documentation
History
 
FOR
Syntax
FOR Variable = Expression TO Expression [ STEP Expression ]
   ...
NEXT

Repeats a loop while incrementing or decrementing a variable.

Note that the variable must be:

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

Examples

DIM iCount AS Integer

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

1 4 7 10 13 16 19

See also

Loop Control Structures