19.12.2012 Views

Computer Programming Concepts and Visual Basic David I. Schneider

Computer Programming Concepts and Visual Basic David I. Schneider

Computer Programming Concepts and Visual Basic David I. Schneider

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

458 <strong>Computer</strong> <strong>Programming</strong> <strong>Concepts</strong> <strong>and</strong> <strong>Visual</strong> <strong>Basic</strong><br />

THE IMMEDIATE WINDOW<br />

You can set the focus to the Immediate window by clicking on it (if visible), by pressing<br />

Ctrl+G, or by choosing “Immediate Window” from the View menu. Although the Immediate<br />

window can be used during design time, it is primarily used in Break mode. When you type a<br />

statement into the Immediate window <strong>and</strong> press the Enter key, the statement is executed at<br />

once. A statement of the form<br />

Print expression<br />

displays the value of the expression on the next line of the Immediate window. In Figure D.1,<br />

three statements have been executed. (When the program was interrupted, the variable numVar<br />

had the value 10.) In addition to displaying values of expressions, the Immediate window also<br />

is commonly used to change the value of a variable with an assignment statement before continuing<br />

to run the program. Note 1: Any statement in the Immediate window can be executed<br />

again by placing the cursor anywhere on the statement <strong>and</strong> pressing the Enter key. Note 2: In<br />

earlier versions of <strong>Visual</strong> <strong>Basic</strong> the Immediate window was called the Debug window.<br />

FIGURE D.1 Three Print Statements Executed in the Immediate Window<br />

THE WATCH WINDOW<br />

You can designate an expression as a watch expression or a break expression. Break expressions<br />

are of two varieties: those that cause a break when they become true <strong>and</strong> those that cause<br />

a break when they change value. At any time, the Watch window shows the current values of<br />

all watch <strong>and</strong> break expressions. In the Watch window of Figure D.2, the type of each expression<br />

is specified by an icon as shown in Table 1.<br />

FIGURE D.2 The Watch Window<br />

TABLE D.1<br />

Watch Type Icons<br />

Icon Type of expression<br />

Watch expression<br />

Break when expression is true<br />

Break when expression has changed<br />

The easiest way to add an expression to the Watch window is to right-click on a variable<br />

in the code window <strong>and</strong> then click on “Add Watch” to call up an Add Watch dialog box. You

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!