|
The loop Do Until allow to execute a block of instructions between the two keywords Do Until and Loop a number of times. The difference from the for loop is in the exit condition. Here the exit condition is a Boolean expression which is evaluated at every loop. If the condition is True then the loop stops.
The syntax is the following:
Do Until (Boolean Expression) ... "Block of instructions" ... Loop
In this loop is possible to exit earlier, using the same technique seen in the For loop. Inserting the instruction "Goto Label" inside a Do Until loop, where Label is a line of code after the keyword Loop.
Let's see and example:
... ... bFound = False Do Until (I > 30) ... ... If (bFound = True) Then Goto ExitDoLoop EndIf ... ... Loop ExitDoLoop: ... ... ...
Inside For or Do Until loops, there can be also other nested loops.
Do Until (I > 30) ... Do Until (A + 1 > 20) ... ... Loop ... ... Loop
Here there are no indexes so the exit condition is exactly the same at every passage, unlike in the For loop.
|