Chapter 8 Debugging Visual Basic Programs 213
- If the form isn’t visible, display it now.
The Debug Test program prompts the user for his or her age. When the user
clicks the Test button, the program informs the user whether he or she is a teenager.
The program still has the problem with 13-year-olds that we identified earlier in the
chapter, however. You’ll open the Debug toolbar now and set a breakpoint to find the
problem.
- If the Debug toolbar isn’t visible, click the View menu, point to Toolbars, and then
click Debug.
The Debug toolbar appears below or to the right of the Standard toolbar. - Click the Start Debugging button on the Standard toolbar.
The program runs and the Debug Test form opens.
- Remove the 0 from the Age text box, type 14 , and then click the Test button.
The program displays the message “You’re a teenager .” So far, the program displays
the correct result.
- Type 13 in the Age text box, and then click the Test button again.
The program displays the message “You’re not a teenager,” as shown in the following
screen shot:
This answer is incorrect, and you need to look at the program code to fix the problem.
- Click the Quit button on the form, and then open the Code Editor.
- Move the mouse pointer to the Margin Indicator bar (the gray bar just beyond the left
margin of the Code Editor window), next to the statement Age = TextBox1.Text in the
Button1_Click event procedure, and then click the bar to set a breakpoint.