Using Breakpoints to Step through Code

Breakpoints can be set on one or more lines of code. When a line of code that has an associated breakpoint is reached, code execution stops and you can then choose to Step Into, Step Over, or Step Out of the code. Selecting the Step Into option from the Debug menu will run the current line of code at the breakpoint. The Step Over option will skip the current line of code at the breakpoint and move on to the next line of code.

Try It Out Setting and Using Breakpoints

It's your turn to set a breakpoint and use it to step through code.

1. Navigate to the TestLoop procedure you created previously in the modBusinessLogic standard module.

2. Set a breakpoint on the Debug.Print and the Next intCounter lines of code, as shown in Figure 2.33. You can set a breakpoint by pointing and clicking the cursor just to the left of the line of code where you want to add a breakpoint.

Figure 2.33

3. Next, open the Immediate Window and run the TestLoop procedure. The code will stop execution at the first breakpoint, as shown in Figure 2.34.

Figure 2.34

4. While at the breakpoint, use the Immediate Window to inquire about the current value of the intCounter variable. To do so, type ? intCounter and press Enter, as shown in Figure 2.35.

Immediate

"ST

testloop

a.

? intcountei

1

<

Figure 2.35

5. The current value of intCounter is displayed in the Immediate Window. You should press F5 or select Run C> Continue to keep executing the lines of code. Execution will stop on each breakpoint.

0 0

Responses

  • bodo
    How to use breakpoints in access vba?
    8 years ago

Post a comment