Err.Raise Method

Named Arguments

Yes

Syntax

object.Raise number, source, description, _
             helpfile, helpcontext


object

Use: Required.

Data Type: Err object

The Err object.


number

Use: Required.

Data Type: Long integer

A numeric identifier of the particular error.


source

Use: Optional.

Data Type: String

The name of the object or application responsible for generating the error.


description

Use: Optional.

Data Type: String

A useful description of the error.


helpfile

Use: Optional.

Data Type: String

The fully qualified path of a Microsoft Windows Help file containing help or reference material about the error.


helpcontext

Use: Optional.

Data Type: Long

The context ID within helpfile.

Description

Generates a runtime error.

Rules at a Glance

  • To use the Raise method, you must specify an error number.

  • If you supply any of the number, source, description, helpfile, and helpcontext arguments when you call the Err.Raise method, they are supplied as values to the Number, Source, Description, HelpFile, and HelpContext properties, respectively. Refer to the entries for the individual properties for full descriptions of and rules for each property.

Programming Tips and Gotchas

  • The Err.Raise method replaces the older Error statement, which shouldn't be used in new code.

  • The Raise method doesn't reinitialize the Err object prior to assigning the values you pass in as arguments. This can mean that if you Raise an error against an Err object that hasn't been cleared since the last error, any properties you don't specify values for still contain the values from the last error.

  • As well as using Raise in a runtime scenario, you can put it to good use in the development stages of your program to test the viability of your error-handling routines under various circumstances.

  • The fact that Err.Number accepts only numbers in the range 0-65536 may appear to be strange at first because the data type of the Error Number parameter in the Raise event is a Long; however deep in the recesses of the Err object, the error code must be declared as an unsigned integer, a data type not supported by VB.

See Also

Err Object, Err.Clear Method, Err.HelpContext Property, Err.Number Property, Chapter 6
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.222.152.241