IsError Function |
Microsoft.VisualBasic.Information
IsError( expression )
An object variable that may be an Exception object
Boolean ( True if expression is an Exception object, False otherwise )
Indicates whether an object is an instance of the Exception class or one of its derived classes
Module modMain Public Sub Main Dim oUnk As Object = "This is an object of subtype String." 'Dim oUnk As Object = 10 Dim oResult As Object = Increment(oUnk) If Not IsError(oResult) Then Console.WriteLine(oResult) Else Console.WriteLine(oResult.Message) End If End Sub Public Function Increment(o As Object) As Object If IsNumeric(o) Then o += 1 Return o Else Dim e As New System.InvalidOperationException Return e End If End Function End Module
In VB 6, the IsError function takes a variant argument and determines if its subtype is vbError . Most commonly, it is used with the CVErr function to determine if the value returned from a function is an error. In VB.NET, the IsError function is used to test whether an object is an instance of the Exception class or its derived classes.
Exception Class