Finding a Variable Definition

When you find an instruction in a VBA procedure that assigns a value to a variable, you can quickly locate the definition of the variable by selecting the variable name and pressing Shift+F2. Or you can choose View | Definition. Visual Basic will jump to the variable declaration line. To return your mouse pointer to its previous position, press Ctrl+Shift+F2 or choose View | Last Position. Let's try it out.

1. Locate the code of the CostOfPurchase procedure.

2. Locate the statement purchCost = CSng(newPurchase).

3. Right-click the variable name and choose Definition from the shortcut menu.

4. Return to the previous location by pressing Ctrl+Shift+F2.

5. Try finding definitions of other variables in other procedures created in this chapter. Each time use a different way to jump to the variable definition.

0 0

Post a comment