Clear 메소드

Err 객체의 모든 등록정보 설정을 지웁니다.

구문

object.Clear

인수:

Object: 필수. 항상 Err 객체입니다.

주석

오류가 처리된 후 Err 객체를 명시적으로 지우려면 Clear를 사용합니다. 예를 들어, 연기된 오류 처리를 On Error Resume Next와 함께 사용하는 경우 이 작업이 필요합니다. BSL은 다음 명령문 중 하나가 실행될 때마다 자동으로 Clear 메소드를 호출합니다.

On Error Resume Next
Exit Sub
Exit Function

다음 예에서는 Clear 메소드의 사용을 보여 줍니다.

예 1:

Sub RaiseAndClearError()
    On Error Resume Next       ' Enable error handling.
    Err.Raise 6                ' Raise an overflow error.
     Output1 =  "error number here " & Err.Number     

     Err.Clear                  ' Clear the error.
    ' Check if the error is cleared.
Output2 = "error number is cleared here " & Err.Number
End Sub
'Output1: error number here 6
'Output2: error number is cleared here 0

예 2:

Sub InnerProcedure()
    On Error Resume Next
    Err.Raise 9         
    Output1 = "Raising error here " & Err.Number
    Err.Clear           
    Output2 = "Error cleared here " & Err.Number
End Sub
Sub OuterProcedure()
    On Error Resume Next
    InnerProcedure      ' Call the inner procedure.
   'OuterProcedure Completed
End Sub
Call OuterProcedure

'Output1: Raising error here 9
'Output2: Error cleared here 0