For Next Loops

    For Next loops are another important part of programming.  The first command if For, which starts the loop.  It needs to have a variable following it though, unlike Do Loops.  The Next command tells it to go back to the top of the loop and start again.  The Next command also requires a variable after it.  This is what it would look like:

Dim Counter As Integer
For Counter = 1 To 10
Next Counter

    First of all I defined the variable Counter.  Then comes For Counter = 1 To 10.  The For part tells the program to start the loop.  It then gives Counter the value 1.   The To 10 tells the program that when Counter equals 10 then end the loop.  The Next Counter goes back to the top of the loop.   Each time it goes back to the top, the loop automatically adds 1 to Counter.   In other words the loop repeats until your variable equals whatever you put where 10 is.  Well, that's all there is to it.

Back

Copyright ©2000 by Kyle Baker.  Please read our disclaimer.