Visual Basic Concepts
Generating and Handling Errors in ActiveX Components
There’s no such thing as an unhandled error in a component. Untrapped errors in a method of your component, or errors you generate using the Raise method of the Err object, will be raised in the client application that called the method.
Raising errors or returning error codes to the client is the appropriate behavior for components. A well behaved component does not intrude on the client application’s user interface by displaying message boxes containing error text.
Users of an application may be blissfully unaware that your component is part of the application they’re using. Seeing error messages from a program unknown to them will not improve their day, or help them solve the problem.
The following topics discuss the strategies and mechanics of returning error information to the client application, for the application’s developer to deal with as she chooses.
Deciding How to Generate Error Messages Discusses two major strategies — raising errors (Basic-style) versus returning error codes (Windows API-style).
Guidelines for Raising Errors from Your Component Discusses the correct format for information in errors raised by components.
Handling Errors in a Component How to handle internal errors, in particular those raised by components your component is using.
For More Information* The basics of error handling are discussed in "Debugging Your Code and Handling Errors," in the *Visual Basic Programmer’s Guide.