Tips for Debugging

To simplify debugging

  • When your application doesn't produce correct results, browse through the code and try to find statements that may have caused the problem. Set breakpoints at these statements and restart the application.

  • When the program halts, test the values of important variables and properties. Use the Immediate window to examine variables and expressions.

To track down a difficult bug

  • First and foremost, make a backup. This is the point at which even experienced programmers frequently lose many hours of work. When you experiment, it is far too easy to accidentally overwrite or delete necessary sections of code.

  • Use the debugging facilities built into the integrated development environment. Attempt to identify the line or lines of code generating the error. Isolate the code. If you can isolate the problem to one block of code, try to reproduce the same problem with this block of code separated from the rest of your program. Select the code, copy it, start a new project, paste the code into the new project, run the new project, and see if the error still occurs.

  • Simplify the problem. If possible, remove any third-party components from your project. Eliminate any code that does not seem to relate to the problem.

  • If you cannot locate a solution and are unable to isolate or resolve the problem with any of these methods, it's time to look for help. See "Technical Support" in the documentation.