1. Technology

Chapter 7 - Using Loops and Timers - Part 1


5 of 8

An Example of a While ... End While Loop
For Each Loop

Here's an example of a While ... End While loop. Suppose you had a statement that asked the Internet Explorer object to open a new web page in your program but you wanted to make sure that the program would wait until the page had completely loaded. (If your program needed information from the new page, the information wouldn't be present until the page had loaded.) You could code the loop this way:

While ie.busy
  sleep 100
End While

(Note: To make the code above actually work, you would also have to create an ie object in your program correctly and this is an advanced topic.)

Another type of loop, called the For Each loop isn't discussed in the book until Chapter 11 because Collections, the type of object that it uses, isn't introduced until then. But, just to be complete, I thought you ought to know now that this additional type of loop is also part of the VB.NET language.

  1. About.com
  2. Technology
  3. Visual Basic
  4. Learn VB.NET
  5. Using Loops and Timers - Part 1

©2014 About.com. All rights reserved.