CS100 Chapter Notes - Chapter 7: The Exit
Document Summary
Loops are used when you need to repeat a piece of code over and over. For loops: used when you know exactly how many times the loop needs to run. Do loops: used when you don"t know the exact number of times a loop should run. For i = 1 to 10 label1. text = label1. text & i. Loops can be used to create a delay in a program. In the previous program all values of the loop appeared at once because the computer is very fast. For i = 1 to 20 step 3. Label1. text = label1. text & & i. You can break out of a for loop at any time by using the command exit for . The general form of a do loop is: For j = 1 to 100000000 larger = more delay. The second option will always allow the loop to run at least once. Timers are controls that loop based on a given interval.