|
Next | ||
For <.counterVar.> = <.initialValue.> To <.finalValue.> [Step <.stepValue.>] ... Next [counterVar] | ||
Parameters: NONE | ||
Returns: NONE | ||
A For-Next, unlike a Repeat-Until or While-EndWhile loop, requires you to specify explicitly the number of iterations you want the loop to go through. At the start of the first iteration the initialValue is assigned to the counter variable (integer type). At the end of each iteration the counter is increased by 1, or if an optional Step statement is given, by the stepValue. If the value of the counter variable is greater than the finalValue, PlayBASIC exits the loop. If the initialValue is greater than the finalValue, stepValue should be a negative number, so that the counter will be decreased. In this case PlayBASIC exits the loop if the value of the counter variable is less than finalValue. FACTS: * For-Next statements must be paired. * The counter variable may follow the Next statement, but is not necessary. * You can exit a For-Next loop anytime with the Exit or the ExitFor statement. Mini Tutorial: Examples of For-Next Loops
Thise code will output:
|
Related Info: | Continue | Each | Exit | ExitFor | For | List | Loops | Repeat | Step | While : |
|
|||||||||||||||||||||||||||||||||||||||
(c) Copyright 2002 - 2024 - Kevin Picone - PlayBASIC.com |