Err Object


Err Object

Class

Microsoft.VisualBasic.ErrObject

Creatable

No

Description

The Err object supplies information about a single runtime error in a Visual Basic program. It also lets you generate errors manually. Because the Err object is a shared object with global scope, you do not need to create an instance of it to use its features.

When an error is generated in your applicationwhether it is handled or notVisual Basic populates the properties of the Err object with the details of the error. You can also generate custom errors through this object, to be handled by other parts of your code or by external assemblies that make use of your components.

When your program reaches an Exit statement (such as Exit Function), a Resume statement, or another On Error statement, the Err object is cleared and its properties reinitialized. This can also be done explicitly using the Err.Clear method.

The following table lists some of the more useful and interesting members of the Err object. Those marked with an asterisk (*) have separate entries in this chapter.

Member

Description

Clear Method *

Resets all the properties of the Err object.

Description Property *

The text description for the active error.

Erl Property

Provides the line number of the active error; equivalent to the intrinsic Visual Basic Erl property. See the Erl Property entry in this chapter for additional information..

GetException Method *

Returns an instance of a System.Exception object related to the active error, an object more commonly used with the new structured exception handling features of VB.

HelpContext Property *

A related help context ID within an online help file, related to the active error.

HelpFile Property *

The path to an online help file, related to the active error.

LastDLLError Property *

The return value of the most recent DLL function call.

Number Property *

The numeric code of the active error (the "error code").

Raise Method *

Forces a specific error to occur immediately.

Source Property *

The name of the application, project, or class that generated the active error.


Usage at a Glance

  • The Err object is not a collection; it contains information about only the most recent error, if one occurred.

  • For a full description of error handling in Visual Basic, see Chapter 11.

See Also

Erl Property, Err.Description Property, Err.HelpContext Property, Err.HelpFile Property, Err.Number Property, Err.Source Property




Visual Basic 2005(c) In a Nutshell
Visual Basic 2005 in a Nutshell (In a Nutshell (OReilly))
ISBN: 059610152X
EAN: 2147483647
Year: 2004
Pages: 712

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net