Small Basic: Infinite For Loops

Warning: Watch out for Infinite Loops!

When using the general form of For loops, you’re setting the start points, end points, and step values for the For loop. Make sure that the loop will eventually end! For example, this loop runs forever:

For N = 1 To 2 Step -1

TextWindow.WriteLine( N )


In this example, the loop counter, N, starts at 1. After the first iteration, because the step size is –1, the value of N is reduced by 1 to become 0. After the second iteration, it becomes –1. So the control variable never goes over 2, and that makes this an infinite loop, a loop that never ends (like Barbie movies).

So be sure to double check your loops!


Do you have any questions? Ask us! We're full of answers and other fine things!

Head to the Small Basic forum to get the most answers to your questions:   

And go to to download Small Basic and learn all about it!


Small and Basically yours

- Ninja Ed & Majed Marji

Comments (1)

Skip to main content