About errors in Visual Basic code
Debugging is a process you use to find and resolve errors, or bugs, in your Microsoft Visual Basic code. There are three types of errors you may encounter as your code runs:
- Compile-time errors occur as a result of incorrectly constructed code. You may have forgotten to balance pairs of statements (such as If and End If or For and Next), or you may have a programming mistake that violates the rules of Microsoft Visual Basic (such as a misspelled word, missing separator, or type mismatch error).
Compile-time errors also include syntax errors, which are errors in grammar or punctuation. These include mismatched parentheses or an incorrect number of arguments passed to a function.
- Run-time errors occur after the application starts to run. Examples of run-time errors include attempting an illegal operation, such as dividing by zero or writing to a file that doesn't exist.
- Logic errors occur when the application doesn't perform as intended and produces incorrect results.
To help you isolate all three types of errors and to monitor how your code runs, the Microsoft Visual Basic Editor provides debugging tools that let you step through your code one line at a time, examine or monitor the values of expressions and variables, and trace procedure calls.