Fixed loops

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

The program above shows a FOR loop in action. However, it is worth noting the finishing value of PupilNo is 6 therefore the program above will display 1,2,3,4,5,6 rather than the often expected 1,2,3,4,5,5.