Visual Basic Do ... Loops

From Techotopia
Revision as of 19:19, 6 August 2007 by Neil (Talk | contribs) (Creating a Visual Basic Do ... Loop)

Jump to: navigation, search

Often when looping it is not possible to know in advance how many times the loop needs to be performed. For example, a loop may need to continue until some specific criteria are met. Under such circumstances the Visual Basic Do ... Loop structure is used.

Creating a Visual Basic Do ... Loop

The Visual Basic Do ... Loop structure can be used in a variety of different ways. The first, basic method involves a simple Do loop with an Exit statement called based on a If statement. The syntax for this type of Do Loop is as follows:

Do
[VB Statements]
If expression Then Exit Do
Loop