Limpa todas as configurações de propriedade do objeto Err.
Sintaxe
object.Clear
Argumentos:
Object: Obrigatório. Sempre o objeto Err.
Comentários
Use Clear para limpar explicitamente o objeto Err após um erro ser corrigido. Isso é necessário, por exemplo, quando você usa o tratamento de erros diferidos com On Error Resume Next. O BSL chama o método Clear automaticamente sempre que uma das seguintes instruções é executada:
On Error Resume Next Exit Sub Exit Function
O exemplo a seguir ilustra o uso do método Clear.
Exemplo 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
Exemplo 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