共用方式為


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