Today we looked at Fixed (unconditional) loops. In VB we use the FOR command to control the execution of the loop.
For .. Next loops are an example of “fixed loops” (unconditional). This is because the number of times the action is executed is fixed in advance by the programmer, using the values of the StartNumber and EndNumber.
For Counter = StartNumber to EndNumber Step Size
Continue reading Fixed loops
A simple sounding task for today’s lesson.
Create a program that displays a triangle made of stars, it should be 5 stars in height. The output should look similar to the image at the side of the screen.
Continue reading It’s full of stars!
How do we roll 100 dice?
We could put in 100 lines to generate the random number and 100 lines to add it to the list box or we can just make use of a FOR…NEXT loop.
This unconditional loop uses an incrementing counter (called counter in the example program) to control the number of repetitions of the loop. Everything between the FOR and NEXT lines is repeated.
What would happen if we wanted to check that the random number generator was really random? How could we test that the numbers are random? Answer after the jump.
Continue reading Visual Basic – Unconditional Loops