We??™ve found our problem.
Before we fix the issue, let??™s take a look at a feature that??™s available from the Locals window
as well as the View menu: the call stack. The call stack lists any procedures that are currently
running, starting with the first procedure you ran. In this case, we ran the AddSalesTotal
macro, which in turn called the GetSalesTotal function.
Click the ellipsis button (...) at the top-right corner of the Locals window to open the Call
Stack window (you can also choose View ?¤ Call Stack or press Ctrl+L). The Call Stack window
for our currently running code is shown in Figure 7-29.
CHAPTER 7 n DEBUGGING AND ERROR HANDLING 270
Figure 7-29. The Call Stack window shows all functions called in the current process.
You??™ll notice in Figure 7-29 that the most current procedure call is at the top of the stack.
Once GetSalesTotal completes and execution returns to AddSalesTotal, it will be removed
from the stack.
8. Close the Call Stack window.
With the code still in break mode, we??™re going to look at one last method of checking variable
values. Then we??™ll fix our problem and run the code successfully.
The Code Window
The code window also has the ability to show us the values of variables. By simply holding
your mouse pointer over any in-scope variable, you can see its value in a tool tip??“style pop-up.
In the VBE code window, move the mouse pointer over any variable to see its value. Figure
7-30 shows the mouse hovering over the cell.
Pages:
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257