Although you can change the loop’s control variable in the body of the loop, we highly recommend that you don’t! Check out this program:
For N = 1 To 10
TextWindow.WriteLine(“Inside loop: N = ” + N)
N = N + 5
TextWindow.WriteLine(“After loop: N = ” + N)
Here’s the output you’d get:
Inside loop: N = 1
Inside loop: N = 7
After loop: N = 13
Changing the loop counter (Line 3) caused the loop to go for two rounds only (instead of 10). Unless you have a compelling reason to tamper with the loop’s counter, please don’t! And don’t tamper with mattress tags!
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 http://blogs.msdn.com/SmallBasic to download Small Basic and learn all about it!
Small and Basically yours
– Ninja Ed & Majed Marji