FOR counter = startvalue TO endvalue [STEP stepvalue]
FOR counter = startvalue DOWNTO endvalue [STEP
A FOR [...] NEXT loop initializes counter to startvalue, then executes the statement block's, incrementing counter by stepvalue until it reaches endvalue. If stepvalue is not explicitly given it will set to 1.
If the DOWNTO is used, then the counter is decremented by the stepvalue or 1 if none is specified.
An EXIT is the proper way to leave a FOR...NEXT, you can also use a GOTO or RETURN statement.