[ Team LiB ] Previous Section Next Section

Debugging a Procedure

The Visual Basic Editor provides several tools to help you write error-free code. However, sometimes a procedure does not act the way you expect it to. To deal with this problem, you can use the Editor's debugging tools to help you locate the source of the trouble. One the most common approaches to debug failed code is to "walk through" the procedure step by step, examining each thing the procedure does. In this way, you can try to locate the exact statement that is causing you trouble.

Stepping Through a Procedure

graphics/1_icon.jpg

Click the View menu, point to Toolbars, and then click Debug.

graphics/2_icon.jpg

Click the first line of the procedure you want to debug.

graphics/3_icon.jpg

Click the Step Into button on the Debug toolbar to run the current statement and then to move to the next line in the procedure.

graphics/4_icon.jpg

Continue clicking the Step Into button to move through the procedure one line at a time, examining the results of the procedure as you go.

graphics/5_icon.jpg

Click the Stop button on the Debug toolbar to halt the procedure at a specific line.

graphics/14inf11.jpg

    [ Team LiB ] Previous Section Next Section