Loops

If you know how many times it needs to be repeated (even if the number will come from a variable) you will use a fixed loop (For…Next).

If you don’t know how many times it needs to be repeated you will use a conditional loop (Loop Until or Do While).

If using a conditional loop, you’ll need to work out what will make the loop stop and create a suitable condition.

For...Next loops increment by 1 with each iteration but this can be changed using the Step keyword.

Example - For...Next     show
Example - For...Next     show
Example – Loop Until     show
Example – Do While     show
Generate VB code:
How many repetitions?



Back to index

mph@ghscomputing.co.uk

Updated 09 December 2018