21.08.2013 Views

OpenOffice.org BASIC Guide.pdf - OpenOffice.org wiki

OpenOffice.org BASIC Guide.pdf - OpenOffice.org wiki

OpenOffice.org BASIC Guide.pdf - OpenOffice.org wiki

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Loops 30<br />

Loop<br />

executes the loop as long as the condition after the Until evaluates to false.<br />

3. The Do...Loop While version<br />

Do<br />

' ... loop body<br />

Loop While A > 10<br />

only checks the condition after the first loop pass and terminates if the condition after<br />

the While evaluates to false.<br />

4. The Do...Loop Until version<br />

Do<br />

' ... loop body<br />

Loop Until A > 10<br />

also checks its condition after the first pass, but terminates if the condition after the<br />

Until evaluates to true.<br />

As in the For...Next loop, the Do...Loop also provides a terminate command. The Exit Do<br />

command can exit at loop at any point within the loop.<br />

Do<br />

If A = 4 Then<br />

Exit Do<br />

End If<br />

' ... loop body<br />

Loop While A > 10<br />

While. . . Wend<br />

The While...Wend loop construct works exactly the same as the Do While...Loop, but with<br />

the disadvantage that there is no Exit command available. The following two loops produce<br />

identical results:<br />

Do While A > 10<br />

' ... loop body<br />

Loop<br />

While A > 10<br />

' ... loop body<br />

Wend

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!