Another common type of loop in Visual Basic is the
DO loop, which would run a piece of code continuously until it is told to stop. On the contrary of some other loops whereby indexes are used to stop the process, in this particular loop, it should be told to stop.
A simple example illustrating the loop is as follows
Dim iIndex1 As Integer iIndex1 = 1 Do Debug.Print iIndex1 iIndex1 = iIndex1 + 1 If iIndex1 = 10 Then Exit Do End If Loop
The above piece of code will take an Index, initialized to 1, and increment it. A
Debug.Print will help print the index to rack the loop. On each loop, the code will verify if the index has reached 10 and if and only if the condition is true, the
Exit Do will be executed, which will stop the loop.