O'Reilly logo

VB.NET Language in a Nutshell, Second Edition by Steven Roman PhD, Paul Lomax, Ron Petrusha

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Name

Err.Number Property

Class

Microsoft.VisualBasic.ErrObject

Syntax

Err.Number

Description

A read/write property containing a numeric value that represents the error code for the last error generated

Rules at a Glance

  • When a runtime error is generated within the program, the error code is automatically assigned to Err.Number.

  • The Number property is updated with an application-defined error whose code is passed as an argument to the Err.Raise method.

  • When using the Err.Raise method in normal code, your user-defined error codes cannot be greater than 65536 nor less that 0. (For an explanation, see the final note in Section of the Err.Raise Method entry.)

  • VB reserves error numbers in the range of 1-1000 for its own trappable errors. In addition, error numbers from 31001 to 31037 are also used for VB trappable errors. In implementing a series of application-defined errors, your error handlers should either translate application errors into VB trappable errors or, preferably, assign a unique range to application-defined errors.

  • When using the Err.Raise method in ActiveX objects, add the vbObjectError constant (-2147221504) to your user-defined error code to distinguish OLE errors from local-application errors.

  • When control returns to the local application after an error has been raised by the OLE server, the application can determine that the error originated in the OLE server and extract the error number with a line of code like the following:

    Dim lError as Long If (Err.Number And vbObjectError) ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required