1. Computing

Using Loops and Timers - Loop Conditions

Starting and Stopping the Loop

By

This article is extracted from page 2 of the lesson for chapter 7 of the About Visual Basic "Complete Course" for VB.NET. Sign up for the entire course at ... this signup page.

When coding a loop, the condition that controls whether the statements inside the loop are executed again can be:

  • While
  • Until
  • To (in: For counter= start To end)

Virtually any program statements can be inside the loop (including more looping statements). The next chapter (which covers program debugging) in the Complete VB.NET Course (see above) shows you a debugging statement that the book doesn't cover, Debug.WriteLine, that will help you understand what the loop does.

The While and Until conditions that control whether the statements inside the loop are executed again can be found either at the beginning of the loop or at the end. The code you would use is shown below.

The While and Until conditions that controls whether the statements inside the loop are executed again can be found either at the beginning of the loop or at the end. In other words, you can code:

Do While condition... Loop

or

Do ... Loop While condition

But you can't have the condition at both the beginning and at the end.

  1. About.com
  2. Computing
  3. Visual Basic
  4. Learn VB.NET
  5. Using Loops and Timers - Loop Conditions>

©2014 About.com. All rights reserved.