Dim Grade (13) as String
Dim Integer as Integer
For Index = 0 to 13 For loop has to have a variable
Grade(Index) = "A"
to be added to...
Sunday, 20 February 2011
Thursday, 17 February 2011
The 3 types of Loops
There are three types of loops:
For...Next Fixed number for identical processing
Do While Monitors the status quo and reacts to changes (sensors)
Loop...Until Target (loop until target is changed)
For...Next
Used to run a piece of code a set number of times. As its name suggest, it is used when a function needs to be carried out for each of several items. It doesn't monitor conditions like the other types of loops
Do While
Runs a piece of code if a condition is true. If the loop starts running, here must be a section inside the loop to either alter the condition or break out of the loop, otherwise it will run indefinitely. It monitors the change in conditions, and reacts to changes accordingly.
Loop...Until loop
Similar to the Do While loop except that it will always run the code inside before checking whether the condition is true; that is, the code inside will always run at least once even if the condition is false. It monitors the change in conditions, and reacts to changes accordingly.
For...Next Fixed number for identical processing
Do While Monitors the status quo and reacts to changes (sensors)
Loop...Until Target (loop until target is changed)
For...Next
Used to run a piece of code a set number of times. As its name suggest, it is used when a function needs to be carried out for each of several items. It doesn't monitor conditions like the other types of loops
Do While
Runs a piece of code if a condition is true. If the loop starts running, here must be a section inside the loop to either alter the condition or break out of the loop, otherwise it will run indefinitely. It monitors the change in conditions, and reacts to changes accordingly.
Loop...Until loop
Similar to the Do While loop except that it will always run the code inside before checking whether the condition is true; that is, the code inside will always run at least once even if the condition is false. It monitors the change in conditions, and reacts to changes accordingly.
Subscribe to:
Posts (Atom)