Using Watches

During debugging, you can use watch expressions to keep track of the data that your program is working with. A watch can be any expression—variables, properties, functions, and so on. Many program bugs are the result of variables and properties taking on unexpected values, and the use of watches is an essential debugging tool.

VBA has two types of watches, so you can choose the one that's right for your needs. Regular watches are displayed in the Watches window, which can be displayed by selecting Watch Window from the View menu. You can have multiple watch expressions in the window, and VBA displays the value, type, and context (module) for each expression. The Watches window is shown in Figure 21.1.

Figure 21.1. The Watches window ...

Get Office® XP Development with VBA now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.