O'Reilly logo

VBScript in a Nutshell, 2nd Edition by Ron Petrusha, Matt Childs, Paul Lomax

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.Description Property

Data Type

String

Description

A read/write property containing a short string describing a runtime error.

Rules at a Glance

  • When a runtime error occurs, the Description property is automatically assigned the standard description of the error.

  • If there is no error (that is, if the value of Err.Number is 0), the value of the Description property is an empty string.

  • For user-defined errors (that is, for errors that you define in your own scripts), you must assign a string expression to the Description property or the error won’t have an accompanying textual message.

  • You can override the standard description by assigning your own description to the Err object for both VBScript errors and user-defined errors.

Example

This example uses the description parameter of the Err.Raise method to return an error message when validating information from an HTML form. The web page containing the form is:

<HTML>
<HEAD>
<TITLE>Register</TITLE>
</HEAD>
<BODY>
<CENTER><H1>Welcome!</H1></CENTER>
Enter Your Name:
<FORM NAME="frmName" METHOD="POST" ACTION="Err_Desc2.asp" >
<INPUT TYPE="text" NAME="txtName">
<INPUT TYPE="submit">
</FORM>
</BODY>
</HTML>

The source code for Err_Desc2.asp is:

<HTML> <HEAD> <TITLE>Welcome to our Web Page</TITLE> <SCRIPT LANGUAGE="VBSCRIPT" RUNAT="Server"> Function ValidateString(sString) If sString = "" Then Err.Raise 61000,, "<H4>Please press the Back button and enter your name.</H4>" Else ValidateString = sString End If End Function </SCRIPT> </HEAD> <BODY> ...

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