Difficulty: Moderately Easy
Step1
Start the Visual Basic Editor and insert a new module.
Step2
Create a new subroutine.
Step3
First, declare a counter variable. For example: Dim m as integer. This variable will keep track of the number of times you run your code. Press Enter.
Step4
Type “For” and give the variable a starting value--usually 1. For example: For m = 1.
Step5
Next, type “To” and the number of times you want to run the code. This is your ending value. For example: For m = 1 To 5. Press Enter.
Step6
Type the code you want to run within the loop. For example: MsgBox ("Hello world!"). Press Enter.
Step7
Type “Next” and the counter variable's name. For example: Next m. This statement will automatically increment the variable until the code within the loop is run the specified number of times.