Setting and Clearing Breakpoints

See Also411ONK

A breakpoint is a line in a program that you set to interrupt normal execution.  You set breakpoints to halt execution at specific statements in a procedurefor example, where you suspect problems may exist.  You clear breakpoints when you no longer need them to halt execution.

To set a breakpoint

   1. Position the insertion point0KIN01C anywhere in a line of the procedure where you want execution to halt.

   2. From the Debug menu, choose Toggle Breakpoint (F9), or use the toolbar shortcut:

     Visual Basic adds the breakpoint and highlights the line using the breakpoint color set in the Environment Options dialog box.

   3. If the application is not running, choose Start (F5) from the Run menu, or use the toolbar shortcut: .  If the application halted during execution, choose Continue (F5) to continue through the program; or choose Restart (Shift+F5) from the Run menu to reset variables and run the application from the beginning.

     Visual Basic halts execution whenever it encounters a breakpoint.

To clear a breakpoint

   1. Position the insertion point0KIN01C anywhere on a line of the procedure containing the breakpoint.

   2. From the Debug menu, choose Toggle Breakpoint (F9), or use the toolbar shortcut:

     Visual Basic clears the breakpoint and removes the highlighting.

 

To clear all breakpoints in the application

         From the Debug menu, choose Clear All Breakpoints.

     Visual Basic clears all breakpoints in the application.

 

Note   Breakpoints set in code are not saved when you save forms and modules.  Closing a project or quitting Visual Basic automatically clears them.  Breakpoints also have no effect when creating an executable file since they are not saved.  A Stop4K739NO statement, however, halts an executable file.

If you set a breakpoint on a line that contains several statements separated by colons (:), the break will always occur at the first statement on the line.

 


See Also

Help:

Adding, Editing, and Deleting Watch Expressions1Z5654F

Debugging Checklist4RVH0A6

 

Programmer's Guide:

Chapter 9, "Debugging"