BB___DO_LOOP

=DO..LOOP= toc

Description
> DO and LOOP cause code to be executed //**while**// a certain condition evaluates to true, or //**until**// a certain condition evaluates to true. **Use DO..LOOP when you want the code to execute at least once**. If the condition evaluates to false, the code will exit the loop.

Syntax
1. do media type="custom" key="6834995"//{code statements}// media type="custom" key="6835005"loop while //booleanExpr//

2. do media type="custom" key="6834995"//{code statements}// media type="custom" key="6835005"loop until //booleanExpr//

3. do while //booleanExpr// media type="custom" key="6834995"//{code statements}// media type="custom" key="6835005"loop

4. do until //booleanExpr// media type="custom" key="6834995"//{code statements}// media type="custom" key="6835005"loop

Hints
> Normally, a loop will execute over and over until a condition evaluates to false, at which point the loop is ended. DO NOT ISSUE A GOTO STATEMENT OR ATTEMPT TO EXIT A DO..LOOP BEFORE THE LOOP HAS FINISHED. If it is necessary to exit a loop before it has finished, issue an EXIT DO command.

Example
code format="vbnet" a = 3 i = 0 ' The basic LOOP UNTIL construct ' Loop UNTIL i equals 3 do       i = i + 1 print "Loop no. "; i   loop until i = a

print ' Program flow continues with DO UNTIL construct i = 0 do until i = a       i = i + 1 print i   loop

print ' Program flow continues with LOOP WHILE construct ' Loop WHILE i does not equal 3 i = 0 do       i = i + 1 print i   loop while i <> a

print ' Program flow continues with DO WHILE construct i = 0 do while i <> a       i = i + 1 print i   loop end

' Exiting a loop prematurely do while i < 100 i = i + 4 print i       if i > 13 then exit do    loop code

Useful Functions
code format="vbnet" Place a useful function using this command here code