Sams Teach Yourself Visual Basic 6 in 24 Hours

Sams Teach Yourself Visual Basic 6 in 24 Hours

By Greg Perry

The Debugger

The debugger gives you a way to search your program's runtime details interactively, looking at variables and trying new values along the way. The debugger is the integrated tool that helps you find program bugs.

Visual Basic's Debug menu, shown in Figure 20.5, gives you a good introduction to the debugger's capabilities. Look through the menu and find the Toggle Breakpoint option. Breakpoints provide the time you need to hunt bugs during the application's execution.

20fig05.gif

Figure 20.5 The Debug menu is ready to help locate bugs.

A breakpoint is a halting point in a program; when you run the program, the program executes as normal until a breakpoint is reached, at which time Visual Basic places you in the debugger.

Visual Basic enters the breakpoint mode (sometimes called the break mode) when you halt a program during execution or when execution reaches a breakpoint that you added to the program before you ran it. The Debug menu options are available during the application's breakpoint mode. These are the three modes that a Visual Basic program can be in:

Visual Basic tells you which mode is current by displaying the word design, run, or break in the title bar at the top of your Visual Basic screen. When you develop the program, the program is in design mode, as indicated by your title bar; when you or the user runs a program, the program is in the run mode; when you halt a program to use the debugger, the program enters the break mode.

The rest of this lesson is about the break mode. While in break mode, your program retains all variable and control values. Therefore, you can halt the program at any time and look at data values from any line of the code. By comparing the values with what you expect the values to contain, you can find where problems are taking place.

Share ThisShare This

Informit Network