Info Ehh

3. Press F8 to execute the Show method. Instead of getting an error, you are taken into the Userform_Initialize procedure.

4. Keep pressing F8 until you get the error message again. You must stay alert. As soon as you encounter the error, the error message box is displayed. Click Debug and you are returned to the userform.Show line. It is particularly difficult to follow the code when the error occurs on the other side of a long loop, as shown in Figure 23.7.

Figure 23.7

With 25 items to add to the list box, you must hit F8 51 times to get through this 3-line loop.

Figure 23.7

With 25 items to add to the list box, you must hit F8 51 times to get through this 3-line loop.

Imagine trying to step through the code in Figure 23.7. You carefully hit F8 five times with no problems through the first pass of the loop. Because the problem could be in future iterations through the loop, you continue to press F8. If there are 25 items to add to the list box, 48 more presses of F8 are required to get through the loop safely. Each time before pressing F8, you should mentally note that you are about to run some specific line.

At the point shown in Figure 23.7, the next press of the F8 key displays the error and returns you to the frmChoose.Show line back in Module1.

This is an annoying situation. When you click Debug and see that the line in error is a line that displays a userform, you need to start pressing the F8 key to step into the userform code until you get the error. Invariably, I get incredibly bored pressing F8 a million times and forget to pay attention to which line caused the error. As soon as the error happens, I am thrown back to the Debug message, which returns me to the frmChoose.Show line of code.

0 0

Post a comment