Example: The Error Subtype

Dim datBirth
Dim lngAge
datBirth = InputBox("Please enter the date on which you were born.")
If IsDate(datBirth) Then
lngAge = GetAge(datBirth)
If Not IsError(lngAge) Then
MsgBox "You are " & lngAge & " years old."
If lngAge = 1000 Then
'This error means that the date was greater
'then the current system date.
MsgBox "That date was greater than the current system date."
'An unknown error occured.
MsgBox "The error " & lngAge & " occured in the GetAge()"_
& "function"
End If
End If
MsgBox "You did not enter a valid date."
End If

Keep in mind that GetAge ( ) is a totally fictional function, and you cannot actually run this code. The point here is only to illustrate how someone might use the Error subtype, and how your code might have to respond to it. You could not easily implement the use of the Error subtype yourself in VBScript because the VBScript does not support the CVErr ( ) conversion function, as Visual Basic does. Therefore, without the aid of Visual Basic, you could never coerce the subtype of a variable to be Error.