-
Step 1
Start the Visual Basic Editor and insert a new module.
-
Step 2
Create a new subroutine.
-
Step 3
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.
-
Step 4
Type "For" and give the variable a starting value--usually 1. For example: For m = 1.
-
Step 5
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.
-
Step 6
Type the code you want to run within the loop. For example: MsgBox ("Hello world!"). Press Enter.
-
Step 7
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.
-
Step 8
Run the program.











