Visual Basic 2008 Programming: Business Applications with a Design Perspective
Chapter 1 Chapter 2 Chapter 3 Chapter 4 Chapter 5 Chapter 6 Chapter 7 Chapter 8 Chapter 9
Chapter 10 Chapter 11 Chapter 12 Chapter 13 Chapter 14 Appendix A Appendix B Appendix C Home
Loading
Last change: February 13 2016 18:48:19.

 Chapter in PDF

Table of Contents

Chapter 7: Repetition
Last change: February 13 2016 18:47:47.
<<PreviousNext>>

7.1   The Do...Loop Structure

One of the structures for repetition is the Do…Loop structure. You can construct the Do...Loop structure with either of the following syntax:

Do [{While|Until} condition] Statements to be repeated Loop

or

Do Statements to be repeated Loop [{While|Until} condition]

where condition = any expression that can be evaluated to True or False; any expression that can be used in an If statement can be used here.
While = the keyword that will make the loop continue as long as the condition is true, and
Until = the keyword that will make the loop continue as long as the condition is false.

When the loop ends, the execution continues to the line below the Loop statement. The following examples illustrate how the various variations of the Do...Loop structure work.
Last change: February 13 2016 18:47:50.
  1. 7.1 The Do...Loop Structure
    1. Example 1. Showing a Sequence of Numbers
    2. Example 2. Reading a Name List and Populating a List Box
    3. The Endless Loop
    4. Do Loop Without a Condition on Either Statement
    5. Example 3. Computing the Value of an Infinite Series
    6. Example 4. Finding the Solution to an Equation Numerically
    7. <<PreviousNext>>