Usage
The following code displays and Input Box asking how many beeps. The code will
then make the computer beep the specified number of times. The code in bold
may be ommitted.
Dim NumBeeps As Integer
NumBeeps = InputBox("How many beeps?")
For Counter = 1 To NumBeeps Step 1
Beep '// beep
Next Counter
The following code counts down from 2000.
For Counter = 2000 To 1 Step -1 '// This counts
down from 2000 to 1
Text1.Text = Counter
Text1.Refresh '// Update Text1
Next Counter
Msgbox "Count down finished"
To exit a For...Next you can use the statement Exit
For. When in a loop, you can also change the value of the Counter variable, so that
the For...Next will miss some values:
For Counter = 1 To 1000 Step 1
'// skip any values between 100 and 600
If Counter = 100 Then Counter = 601
'// set text value
Text1.Text = Counter
Text1.Refresh '// Update Text1
Next Counter
Using this code, you will notice that when the text box is counting up, it
will miss all numbers between 100 and 600