Debugging, Input Validation, FiLe Processing, And Error HandLing

This chapter teaches you techniques for preventing runtime errors through input validation and error handling. You also see how to debug your VBA code using common VBE debugging windows. In addition, I show you how VBA manages file input and output (file I/O).


Sooner or later, all programmers seek the holy grail of debugging. The holy grail of debugging is different for each programming language. VBA programmers are very lucky the VBE provides a multitude of debugging facilities not found in many other programming environments.

As a programming instructor and lecturer, I've often encouraged my Visual Basic students to use the VBE debugging facilities not only to debug programs, but to see how the program flows, how variables are populated, and how and when statements are executed. In other, less friendly languages, programmers must take for granted the order in which their statements are executed. In VBA, you can actually step through your application one statement at a time. You can even go back in time to reexecute statements, something I show you a little later on.

In this section, I show you how to leverage each of the following VBE debugging facilities:

• Break statements

• Immediate window

• Locals window

Was this article helpful?

0 0

Post a comment