Err.Clear Method


Err.Clear Method

Class

Microsoft.VisualBasic.ErrObject

Syntax

     Err.Clear(  ) 

Description

The Clear method explicitly resets all the properties of the Err object after an error has been handled.

Usage at a Glance

  • Use the Clear method at your convenience when you want to make sure that an error contained in the Err object is truly a new error and not a leftover error from an earlier block of code.

  • The Err object is automatically reset when any Resume, On Error, or Exit statement is executed.

Example

     On Error Resume Next     Err.Clear(  )     Call ErrorProneRoutineWithNoHandler(  )     If (Err.Number <> 0) Then        ' ----- The generated error must have come from the        '       subroutine call, since the Clear(  ) method        '       set Err.Number to 0.        MsgBox ("The Error : " & Err.Description & vbCrLf _               & " was generated in " & Err.Source & ".")     End If 

See Also

Err Object, Err.Raise Method




Visual Basic 2005(c) In a Nutshell
Visual Basic 2005 in a Nutshell (In a Nutshell (OReilly))
ISBN: 059610152X
EAN: 2147483647
Year: 2004
Pages: 712

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net