Microsoft Visual Basic 2010 Step by Step eBook

(Tina Meador) #1

Chapter 8 Debugging Visual Basic Programs 219



  1. Select the expression Age < 20, and then add it to the Watch window.


Age < 20 is a conditional expression, and you can use the Watch window to display its
logical, or Boolean, value. Your Watch window looks like this:

Now step through the program code to see how the values in the Watch 1 window change.


  1. Click the Step Into button on the Standard toolbar.


Tip Instead of clicking the Step Into button on the Standard toolbar, you can press the
F8 key on the keyboard.

The Age variable is set to 20, and the Age < 20 condition evaluates to False. These values
are displayed in red type in the Watch window because they’ve just been updated.


  1. Click the Step Into button three more times.


The Else clause is executed in the decision structure, and the value of the TextBox2.Text
property in the Watch window changes to “You’re not a teenager .” This conditional test
is operating correctly. Because you’re satisfied with this condition, you can remove the
test from the Watch window.


  1. Click the Age < 20 row in the Watch window, and then press the DELETE key.


Visual Studio removes the value from the Watch window. As you can see, adding
and removing values from the Watch window is a speedy process.
Leave Visual Studio running in debugging mode for now. You’ll continue using the Watch
window in the next section.
Free download pdf