What is a For Loop?
A For Loop is used to iterate through a script a certain amount of times. Personally, I use it to check conditions for each item within a group, list or array.
How do I use a For Loop?
To create a For Loop you first need to decide how many times you want a script to run. You also want to create a script which will be ran.
Once you have decided on both of those options you will want to set it out in the following format:
For {variableName} As Integer = {start} To {end}
Next
Now we need to swap the parts surrounded by {} with the real programming. The following script uses the variable as 'i' because 'i' is a convention in programming as a variable name that doesn't server any major purpose.
The script will output the value of 'i' (which will increase by one for each loop) in a messagebox each time it loops...
For i As Integer = 0 To 10
MsgBox(i)
Next
So the above script outputs the numbers 0 to 10 (11 different messageboxes). We can do the same thing but using variables just as easily...
Dim start As Integer = 0
Dim endPosition As Integer = 10
Dim output As String = "Message"
For i As Integer = start To endPosition
MsgBox(output)
Next