Two Debug Tricks

<< Click to Display Table of Contents >>

Navigation:  Managing Quality, Performance, Bugs and Errors >

Two Debug Tricks

Many years ago I read that one of the differences between a programmer and a power user was whether they used a debug tool such as the debug VBA. This article shows two useful debug tricks


I was contemplating a radical change to a program and I decided I would test  it offsite. Problem was that I didn't have all the tables offsite to make it work. My program was in the wrong place to start successfully (Figure 1) and I would have to spend quite a bit of time setting up a table I didn't have. So I decided I needed to trick the program using the debug tool. I pressed Control Break keys together.




Figure 1 - Wrong Place - Press Control Break


The debug option popped up on the screen as in Figure 2



Figure 2 - Choose debug



Because I was missing the linked table, the program was at the wrong place in the code as highlighted by the yellow arrow in Figure 3. I then click on the arrow and drag the focus of the code (the arrow) upto the line that I want. We have now tricked the code into recommencing in a difference place.



Figure 3 - Move the focus to execute a different line of code


My problem now is that I don't have the correct data for the program to work correctly. I then do something that I have always thought was really cool in the debugger, I enter the information directly into the variable itself in the immediate window (shown in Figure 4). The ability to enter data of your own choice is so useful for testing. If you haven't ever used it, go and practice it now as its one of the great little tricks that makes a power user a programmer.



Figure 4 - Enter your own values into variables in the Immediate window..


Key Sequences Used in This Tip

Control Break
Drag the line with the mouse
Control G - Open the immediate window
Type data in the Immediate Window