Equivalent Loops All the following pieces of code do the some thing Loop through a section of code 5 (Five) times.
For .... Next
VB
For i as integer=1 To 5
' < Looping section of code >
Next i
Do ... Loop Until
VB
Dim i as integer=1
do
' < Looping section of code >
i = i + 1
Loop Until i>5
Do ... Loop Until (Method 2)
VB
Dim i as integer=0
do
i = i + 1
' < Looping section of code >
Loop Until i=5
Do ... Loop WhileCODE
Dim i as integer=1
do
' < Looping section of code >
i = i + 1
loop while i<=5
Do ... Loop While (Method 2)CODE
Dim i as integer=0
do
i = i + 1
' < Looping section of code >
loop while i<5
While ... End WhileCODE
Dim i as integer=0
While i<5
i = i + 1
' < Loop section of code >
End while
While ... End While (Method 2)CODE
Dim i as integer=1
While i<=5
' < Loop section of code >
i = i + 1
End while
I hope you find these examples useful in developing your programming skills.