Visual Basic Language Reference  

Clear Method

Clears all property settings of the Err object.

object.Clear

Parameter

object

Always the Err object.

Remarks

Use Clear to explicitly clear the Err object after an error has been handled, such as when you use deferred error handling with On Error Resume Next. The Clear method is called automatically whenever any of the following statements executes:

Example

This example uses the Err object's Clear method to reset the numeric properties of the Err object to zero and its string properties to zero-length strings. Without the call to Clear, the second call to MsgBox would display the same error message.

Sub ClearErr()
   ' Produce overflow error
   On Error Resume Next
   Dim zero As Integer = 0
   Dim result As Integer = 8 / zero
   MsgBox(Err.Description)
   Err.Clear()
   MsgBox(Err.Description)
End Sub

See Also

Description Property | Err Object | HelpContext Property | HelpFile Property | LastDLLError Property | Number Property | On Error Statement | Raise Method | Source Property

Applies To

Err Object