Error Messages (Visual Basic)
Error messages can occur while an application is running, either within the Visual Basic environment or as a stand-alone executable file. Some of these can also occur during design time or compile time. You can test and respond to trappable errors using the On Error statement and the Err object's Number property. Unused error numbers in the range 1 to 1000 are reserved for future use by Visual Basic.
Note
The description "Application-defined or object-defined error" occurs when an error is generated using the Err object's Raise method or the Error statement, but the number does not correspond to an error defined by the Visual Basic language. Such errors may be defined by the host application (for example, Microsoft Excel or Visual Basic), but if you want to generate them from code, you must use the Raise method and fill in all relevant arguments.
While developing in Visual Basic, you can get information from Help on a message by pressing F1. Likewise, you can press F1 on error messages shown in the Task List window.
In This Section
- How to: Get Information about Visual Basic Compiler Errors
Explains the concept of compiler errors and how to get help for particular error messages.
- How to: Get Information about Visual Basic Run-Time Errors
Explains the concept of run-time errors and how to get help for particular error messages.
- Visual Basic Compiler Messages
Contains the Visual Basic error messages that occur at compile time.
- Visual Basic Run-Time Messages
Contains the Visual Basic error messages that occur at run time
Related Sections
- Exception and Error Handling in Visual Basic
Lists links to topics related to exception handling in Visual Basic.
- Walkthrough: Structured Exception Handling
Illustrates how to use the Try...Catch...Finally statement to handle exceptions.