Repeats a block of statements a specified number of times.
For IndexVariable = StartValue { To | Downto } FinalValue [ Do ]
[ statements ]
Next
IndexVariable is an integer variable (not array). StartValue and FinalValue are numeric expressions.
The Do keyword is optional. To or Downto is required.
The IndexVariable starts at the StartValue and is incremented or decremented by 1 for each loop until the IndexVariable is greater than (or less than when using Downto) the FinalValue.
For i=1 To 5 Do
Print i;
Next
! This will print 1 2 3 4 5
! i is now 6
For i=5 Downto 1
print i;
Next
! This will print 5 4 3 2 1
! i is now 0
For i=0 To -1
print i
Next
! This will not print
! i is 0