on Error goto Proc_Err ..... ........ ......Proc_Err: ShowError "frmlogin", "CmdOK", Err.Num, Err.Description '*错误处理模块 Public Sub ShowError(strModule As String, strProcedure As String, lngErrorNUmber As Long, _ strErrorDescription As String) On Error GoTo Proc_Err Dim strMessage As String '错误信息 Dim strCaption As String '提示框标题 Dim intLogFile As Integer '错误日志文件 intLogFile = FreeFile
.....
........
......Proc_Err:
ShowError "frmlogin", "CmdOK", Err.Num, Err.Description
'*错误处理模块
Public Sub ShowError(strModule As String, strProcedure As String, lngErrorNUmber As Long, _
strErrorDescription As String)
On Error GoTo Proc_Err
Dim strMessage As String '错误信息
Dim strCaption As String '提示框标题
Dim intLogFile As Integer '错误日志文件 intLogFile = FreeFile
Open "errreport.txt" For Append As #intLogFile
Print #intLogFile, "****** 错误发生时间-" & VBA.Now & " ******"
Print #intLogFile, "错误号:" & lngErrorNUmber
Print #intLogFile, "错误描述:" & strErrorDescription
Print #intLogFile, "过程名:" & strProcedure
Print #intLogFile, "模块名:" & strModule
Print #intLogFile, ""
Close #intLogFile
strMessage = "Error:" & strErrorDescription & vbCrLf & vbCrLf & _
"Module:" & strModule & vbCrLf & _
"Procedure:" & strProcedure
strCaption = "Unexpect Error! Version: " & _
Str$(App.Major) & "." & Str$(App.Minor) & "." & _
Format(App.Revision, "0000")
MsgBox strMessage, vbCritical, strCaption
Proc_Exit:
Exit Sub
Proc_Err:
Resume Next
End Sub
End Try
####################################################################################### 曾记否,蓝天上的那朵白云
慢慢的,不知不觉的飘走了
-------------------------------------------------------------------