Important Notice
The pages on this site contain documentation for very old MS-DOS software,
purely for historical purposes.
If you're looking for up-to-date documentation, particularly for programming,
you should not rely on the information found here, as it will be woefully
out of date.
Debugging Programs
◄Contents► ◄Index► ◄Back►
──────────────────────────────────────────────────────────────────────────────
Debugging Programs
■ Debugging is the process of finding and resolving errors (bugs) in your
code. See: ◄Error Types Definition►
■ To debug code in Visual Basic:
1. Print the code
Some developers find it easier to read code on paper than online.
2. Run the application to find errors
• From the Run menu, choose Start, or press F5 to begin running the
application.
• Run until an error stops execution, or halt execution manually when
you suspect an error by pressing Ctrl+Break.
• Resolve the errors.
• From the Run menu, choose Continue, or press F5 to continue running
the application.
3. Use debugging tools and techniques to isolate bugs and monitor code
• Set breakpoints to halt execution at certain points to look for
problems such as incorrect variable types, mix-ups in variable names,
flaws in logical comparisons, endless loops, garbled output, and
problems with arrays. You can also set breakpoints to monitor program
flow or to examine information in the current state.
See: ◄Setting Breakpoints►
• Single step or procedure step through your code to trace through the
application as it's running. See: ◄Tracing Execution►
• Use the Immediate window to either test individual lines of code (or
procedures) or change values. See: ◄Using the Immediate Window►
• Use the Debug window to display variable values.
4. Try out bug fixes and then make edits
• Test individual lines of new or debugged code in the Immediate
window.
• Search and replace code for all occurrences of an error, checking
other procedures, forms, or modules with related code.
• From the Run menu, choose Restart, or press Shift+F5 to reset
application variables and properties and restart the application from
the beginning.
■ These debugging techniques can also be applied in different sequences.
See: ◄Run and Debug Keys►
◄Tutorial: Debugging Your Application►