VBS Tutorial: method-Raise Method

Source: Internet
Author: User

Raise Method

Generate runtime error

object.Raise(number, source, description, helpfile, helpcontext)

Parameters

Object

Should beErrObject.

Number

LongThe integer subtype, indicating the nature of the error. The VBScript error range is between 0 and 65535.

Source

Name the string expression of the object or application that originally generated an error. Use a form when setting this attribute for an Automation ObjectProject. class. If no value is specified, the program design ID of the current VBScript project is used.

Description

The string expression that describes the error. If not specified, checkNumber. If you can map it to an error code During VBScript running, use the string provided by VBScriptDescription. If notNumberIf the corresponding VBScript error occurs, the common error message is used.

Helpfile

The complete and valid path of the Help file. You can find the Help information for this error in the Help file. If not specified, VBScript uses the complete and valid drive, path, and file name of the VBScript Help file.

Helpcontext

Context ID, IDHelpfile. If this parameter is omittedNumberThe incorrect VBScript Help file context ID corresponding to the attribute (if any ).

Description

BesidesNumberAll other parameters are optional. If you useRaiseWithout specifying some parameters, andErrIf the property settings of an object contain uncleared values, these values become incorrect values.

Set the error code in Automation objectNumberConstantVbObjectErrorAdd the error code number. For example, to generate error 1050, you canNumberAttribute Value:VbObjectError+ 1050.

The following example illustrates how to useRaiseMethod:

On Error Resume NextErr.Raise 6  'Overflow error.MsgBox ("Error # " & CStr(Err.Number) & " " & Err.Description)Err.Clear    'Clear the error.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.