Visual Basic allows a procedure to be repeated as many times as long as the processor could support.
A D V E R T I S E M E N T
This is generally called looping . Visual Basic supports several versions of the Do statement.
Do While loop
The Do While loop is perhaps the most common looping statement that you'll put in Visual Basic programs.
Here is the format of the Do While loop:
Do While condition
'Block of one or more VB statements
Loop
The following example shows the use of Do Loop in VB
Do while counter <=1000
num.Text=counter
counter =counter+1
Loop
or
The above example can be rewritten as
Do
num.Text=counter
counter=counter+1
Loop until counter>1000
2.For....Next Loop
The format is as follows:
For counter=startNumber to endNumber (Step increment)
One or more VB statements
Next
The following example shows the use of For....Next Loop in VB
(a) For counter=1 to 10
display.Text=counter
Next
(b) For counter=1 to 1000 step 10
counter=counter+1
Next
(c) For counter=1000 to 5 step -5
counter=counter-10
Next