18.01.2013 Views

VBScript Reference Manual for InduSoft Web Studio

VBScript Reference Manual for InduSoft Web Studio

VBScript Reference Manual for InduSoft Web Studio

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

<strong>InduSoft</strong> <strong>Web</strong> <strong>Studio</strong> <strong>VBScript</strong> <strong>Reference</strong> <strong>Manual</strong><br />

and the other Err to in<strong>for</strong>m the user which object originally caused the error, its<br />

description of the error, and so <strong>for</strong>th.<br />

When generating an error from code, Source is your application's programmatic<br />

ID.<br />

Example On Error Resume Next<br />

Err.Raise 8 ‘User defined error<br />

Err.Description = “Invalid input”<br />

Err.Source = “MyApplication”<br />

MsgBox “Error Type = “ &Err.Description & “ generated in “ & Err.Source<br />

Method Clear<br />

Function: Clears all property settings in the Err object<br />

Usage: Err.Clear<br />

Arguments: none<br />

Remarks: Use Clear to explicitly clear the Err object after an error has been handled. This<br />

is necessary, <strong>for</strong> example, when you use deferred error handling with On Error<br />

Resume Next. <strong>VBScript</strong> calls the Clear method automatically whenever any of<br />

the following statements is executed:<br />

• On Error Resume Next<br />

• Exit Sub<br />

• Exit Function<br />

Method Raise<br />

Function: Generates a run-time error<br />

Usage: Err.Raise(number, source, description, helpfile, helpcontext)<br />

Arguments: number<br />

A Long integer subtype that identifies the nature of the error. <strong>VBScript</strong> errors<br />

(both <strong>VBScript</strong>-defined and user-defined errors) are in the range 0–65535.<br />

source<br />

A string expression naming the object or application that originally generated<br />

the error. When setting this property <strong>for</strong> an Automation object, use the <strong>for</strong>m<br />

project.class. If nothing is specified, the programmatic ID of the current<br />

<strong>VBScript</strong> project is used.<br />

description<br />

A string expression describing the error. If unspecified, the value in number is<br />

examined. If it can be mapped to a <strong>VBScript</strong> run-time error code, a string<br />

provided by <strong>VBScript</strong> is used as description. If there is no <strong>VBScript</strong> error<br />

corresponding to number, a generic error message is used.<br />

helpfile<br />

The fully qualified path to the Help file in which help on this error can be<br />

found. If unspecified, <strong>VBScript</strong> uses the fully qualified drive, path, and file<br />

name of the <strong>VBScript</strong> Help file.<br />

helpcontext<br />

The context ID identifying a topic within helpfile that provides help <strong>for</strong> the<br />

error. If omitted, the <strong>VBScript</strong> Help file context ID <strong>for</strong> the error corresponding<br />

to the number property is used, if it exists.<br />

Remarks: All the arguments are optional except number. If you use Raise, however,<br />

without specifying some arguments, and the property settings of the Err object<br />

contain values that have not been cleared, those values become the values <strong>for</strong><br />

your error.<br />

When setting the number property to your own error code in an Automation<br />

object, you add your error code number to the constant vbObjectError. For<br />

example, to generate the error number 1050, assign vbObjectError + 1050 to<br />

the number property.<br />

Example On Error Resume Next<br />

Dim Msg<br />

<strong>InduSoft</strong>, Ltd. 201

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!