FOR...NEXT

From QB64 Wiki
Revision as of 21:21, 9 September 2009 by imported>Clippy (Created page with 'The '''FOR''' statement creates a counter loop using specified number parameters. ''Syntax:'' :: FOR count_variable = start_value TO stop_value [STEP interval] :: NEXT [count…')
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

The FOR statement creates a counter loop using specified number parameters.


Syntax:

FOR count_variable = start_value TO stop_value [STEP interval]
NEXT [count_variable]


  • Count variable name is required and may be used with the NEXT loop end.
  • Start value and stop value are number values or variables for the count span.
  • STEP is used for intervals that are not 1 or are negative count intervals.
  • If the start value is greater than the stop value, then a minus STEP interval is required.


Example:

FOR i = 100 TO 0 STEP -2
totaleven% = i + totaleven%
NEXT
PRINT totaleven%

Results: 2550


See also: DO...LOOP


Navigation:

Go to Keyword Reference - Alphabetical

Go to Keyword Reference - By usage