On Error Resume Next 'Try Dim i : i = 1/0 '产生一个错误 If Err.Number = 1 Then 'catch number = 1的错误 'doNothing End if If Err.Number = 2 Then 'catch number = 2的错误 Err.Raise Err.Number 'throw End if If Err.Number <> 0 Then 'catch 所有错误 Msgbox "No.:" & vbTab & vbTab & Err.Number & vbNewLine & _
"Source:" & vbTab & vbTab & Err.Source & vbNewLine & _
"Description:" & vbTab & Err.Description & vbNewLine, _
vbCritical, "Error!" End If Err.Clear 'finally, clean up error.