A loop is a repetitive procedure that is designed to repeat a given set of instructions.
Loops are absolutely essential for getting work done. You know how computer software saves you so much time, by doing the tedious repetition of tasks? Our good hero the loop is the one to blame. Other terms associated with loops: Looping, Iterating, Iteration, Enumerating, Enumeration, Cycling
Option
Strict
On
Public
Class
Form1
Private
Sub
Button1_Click(
ByVal
sender
As
System.
Object
,
e
System.EventArgs)
Handles
Button1.Click
1:
Dim
Counter
Integer
= 0
2: Counter = Counter + 1
3:
'You can put
4:
'code in-between
5:
If
Counter < 100
Then
GoTo
2
6: MsgBox(
"We have reached "
& Counter &
", so the loop is complete!"
)
End
Count
Do
'Code in here
Count = Count + 1
Loop
Until
Count = 100
MsgBox(
& Count &
While
Count < 100
Exit
Result
For
I
To
100
Result = I
Next
& Result &
= 500
Step
-2
500000
I = 100
200
Select
Case
Mod
1
Result = Result + 1
Continue
'Only arrive here when I is an odd number
Array()
= {25, 25, 25, 25}
Each
Number
In
Array
Result = Result + Number
There are many many uses of looping in Visual basic, and programming in general would not be complete without the ability to iterate.
I hope you find this helpful, Please update this article if I left anything out!