Visual Basic Language Reference  

IsError Function

Returns a Boolean value indicating whether an expression is an exception type.

Public Function IsError(ByVal Expression As Object) As Boolean

Parameter

Expression
Required. Object expression.

Remarks

IsError returns True if the expression represents an Object variable that derives from the Exception class in the System namespace.

An exception that derives from System.Exception can be caught with the Try...Catch...Finally statements.

Example

This example uses the IsError function to check if an expression represents a system exception.

Dim ReturnVal As Object
Dim BadArg As String   ' Name of out-of-range argument.
Dim MyCheck As Boolean
' ...
ReturnVal = New System.ArgumentOutOfRangeException(BadArg)
' ...
MyCheck = IsError(ReturnVal)   ' Returns True.

See Also

IsArray Function | IsDate Function | IsDBNull Function | IsNothing Function | IsNumeric Function | IsReference Function | Object Data Type | TypeName Function