Take a look at this For loop:
For N = i To t Step s
Statement(s)
EndFor
i is the initial value, t is the terminal value, and s is the step size. You can use this formula to find the number of times your program runs the loop (the iteration count):
The answer’s truncated (if needed) to give you an integer; the decimal part is removed. Of course, the minimum iteration count’s zero. This table shows you some examples:
Example |
i, t, s |
Formula |
Iteration Count |
For N = 1 To 20 Step 3 |
1, 20, 3 |
7.33 |
7 |
For N = 5 To 150 Step 40 |
5, 150, 40 |
4.625 |
4 |
For N = 20 To 5 Step –3 |
10, 5, –3 |
6 |
6 |
For N = 2.5 To 8.0 Step 0.5 |
2.5, 8.0, 0.5 |
12 |
12 |
Head to http://blogs.msdn.com/SmallBasic to download it and learn all about it!
Small and Basically yours,
– Ninja Ed & Majed Marji
Computers Today (part 1 of 6)
blogs.msdn.com/…/computers-today.aspx
…..
CS SPOTLIGHT: Girls in computer programming… why it matters!!!
blogs.msdn.com/…/cs-spotlight-girls-in-computer-programming-why-it-matters.aspx
…
Computational Thinking – Videos & Papers by Jeannette Wing
blogs.msdn.com/…/computational-thinking-videos-amp-papers-by-jeannette-wing.aspx