Using the Locals Window

The Locals window acts like a dynamically generated list of watches for the current procedure. As execution moves from one procedure to another in break mode, the Locals window is updated to show a list of local variables and their values (see Figure 31-18).

Locals ®

<Ready>

Expression

| Value

| Type

S Me strTaskName intTaskNum

"Write chapter

String

Integer

Figure 31-18. Click the plus sign (+) next to the expression "Me" to see the value of every property, variable, and function referenced by or defined in your project.

If a variable can be assigned a value in more than one location in a procedure (such as when a different value is assigned to the same variable, depending upon which path is taken through a decision structure), it is listed once for each possible assignment. Assuming that the procedure runs successfully, only one of these occurrences will have an entry in the Value column by the time execution moves out of the procedure.

Unlike the Watches window, which is read-only, you can modify items in the Value column to test different actions taken by your code. If you had a decision structure in your code, for example, that took different actions according to the value of a local variable, you could do the following:

1 Insert a breakpoint at the beginning of the structure and then run your macro.

2 When execution enters break mode, step through the decision structure to see the results.

Figure 31-17. Set the Watch Type to specify whether you want to watch the expression or test its value to determine when to enter break mode.

3 At the end of the decision structure (or at any time before execution moves to a different procedure), change the value of the variable in the Locals window to h something else. is

4 Select the line with the breakpoint, use Ctrl+F9 to force execution to return to that J2 line, and then step through the decision structure again. °

Project Management Made Easy

Project Management Made Easy

What you need to know about… Project Management Made Easy! Project management consists of more than just a large building project and can encompass small projects as well. No matter what the size of your project, you need to have some sort of project management. How you manage your project has everything to do with its outcome.

Get My Free Ebook


Post a comment