Page 143 - Open Soource Technologies 304.indd
P. 143
Unit 6: VB Control Structure
[Type 3 into the box and press the OK button.]
In Examples 1 and 2, the condition was checked at the top of the loop that is, before the statements
were executed. Alternatively, the condition can be checked at the bottom of the loop when the
statement Loop is reached. When Visual Basic encounters a Do loop of the form
Do
statement(s)
Loop Until condition
it executes the statements inside the loop and then checks the truth value of condition. If condition
is true, then the program continues with the line after the Loop statement. If condition is false,
then the entire process is repeated beginning with the Do statement. In other words, the
statements inside the loop are executed once and then are repeatedly executed until the condition
is true. Figure 6.3 shows the pseudocode and flowchart for this type of Do loop.
LOVELY PROFESSIONAL UNIVERSITY 137