2.5 - Loops, Loops, Loops, Loops, Loops, Loops, Loops....
Loops allow programmers to repeat lines of code several times, until an exit clause is met.
Loops can take two different
forms.
You can have a Do
..... While.... Loop or you can have a For ... Next Loop
Do .... While....
Loop
While intCounter is less
than 11, this loop will repeat. As soon as intCounter
is not < 11, so when it becomes equal, it will then exit the loop.
For... Next Loop
The above loop will output
a message box each time through the loop.
The counter for the loop is called intNumber, and it will increment by 1 each
time through the loop.
Can you figure out how many Message Boxes will be outputted?
1... Your task in this
tutorial is to create a program that will prompt the user for a two numbers.
The program will then add up all the numbers that fall between these two numbers.
For example, if the user enters 3 and 7 the program will add 3 + 4 + 5 + 6 +
7.
You will probably need a variable to keep track of the running total (ie: intTotal = intTotal + NextNumber)