Action
Execute a block of statements a number of times.
Syntax
FOR var = start TO/DOWNTO end [STEP value]
Remarks
Var |
The variable counter to use |
Start |
The starting value of the variable var |
End |
The ending value of the variable var |
Value |
The value var is increased/decreased with each time NEXT is encountered. |
var : Byte, Integer, Word, Long, Single.
start: Byte, Integer, Word, Long, Single, Constant.
end : Byte, Integer, Word, Long, Single, Constant.
step : Byte, Integer, Word, Long, Single, Constant.
For incremental loops you must use TO.
For decremental loops you must use DOWNTO.
You may use TO for a decremental loop but in that case you must use a negative STEP :
For a = 10 To 1 STEP -1
You must end a FOR structure with the NEXT statement.
The use of STEP is optional. By default a value of 1 is used.
See also
Example
Dim Y As Byte , A As Byte,x as byte
y = 10 'make y 10
For A = 1 To 10 'do this 10 times
For X = Y To 1 'this one also
Print X ; A 'print the values
Next 'next x (count down)
Next 'next a (count up)
Dim S As Single
For S = 1 To 2 Step 0.1
Print S
Next
End