Difference between revisions of "Visual Basic Do ... Loops"
From Techotopia
(New page: 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...) |
(→Creating a Visual Basic Do ... Loop) |
||
Line 5: | Line 5: | ||
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: | 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''' | + | '''Do'''<br> |
− | + | ''[VB Statements]''<br> | |
− | + | '''If''' ''expression'' '''Then Exit Do'''<br> | |
− | '''Loop''' | + | '''Loop'''<br> |
Revision as of 19:19, 6 August 2007
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