📄 moderror.bas
字号:
Attribute VB_Name = "modError"
'****************************************
'汉化: 小聪明 coolzm@sohu.com
'小聪明的主页VB版: http://coolzm.533.net
'****************************************
Option Explicit
'------------------------------------------------------------
' SC Productions
' Name: RFN
' Company: SCP
' Purpose: LogErr
' Parameters: Logs an error in Errors.log in your applications
' directory, and continues running your program.
' Arguments: Three optional strings, which will be logged for
' additional information, if desired.
' Date: June,19 99
'------------------------------------------------------------
Dim lFatal As Boolean
Public Sub LogErr(Optional strInput1 As String, _
Optional strInput2 As String, _
Optional strInput3 As String)
Dim strMsg As String '弹出的错误对话框的内容
Dim strTitle As String '弹出的错误对话框的标题
Dim OldErrDesc As String
Dim OldErrNum As Long
Dim intFile As Integer
If Err.Number = 0 Then
Exit Sub
Else
'XXXX
End If
OldErrDesc = Err.Description
OldErrNum = Err.Number
If lFatal = True Then
strMsg = "致命的"
Else
strMsg = "未知的"
End If
strMsg = strMsg & " 错误: " & Err.Description & vbCrLf & _
vbCrLf & "请联系你的产品供应商 " & _
"向他们通报你的错误"
strTitle = App.Title & " v" & App.Major & "." & App.Minor
strTitle = strTitle & "错误号 # " & Err.Number
MsgBox strMsg, vbExclamation + vbOKOnly, strTitle
On Error GoTo ErrWhileLogging:
'致命错误
intFile = FreeFile
Open App.Path & "\errors.log" For Append As #intFile
Print #intFile, "----------------------------------------------------"
If lFatal Then
Print #intFile, "Fatal"
Else
Print #intFile, "Non-Fatal"
End If
Print #intFile, " Error in " & App.Path & "\";
Print #intFile, App.Title & " v" & App.Major & "." & App.Minor & " "
'If Not IsNull(strInput1) Then
'Print #intFile, strInput1
'End If
If Not IsNull(strInput2) Then
Print #intFile, strInput2; "XXXXXXXXXXXXXXXXXXXX"
End If
'If Not IsNull(strInput3) Then
'Print #intFile, strInput3
'End If
Print #intFile, Date$ & " " & Time$
Print #intFile, "Error #" & OldErrNum
Print #intFile, "" & OldErrDesc & vbCrLf
Print #intFile, "----------------------------------------------------"
Close #intFile
Exit Sub
ErrWhileLogging:
strMsg = "致命的错误" & vbCrLf & _
"请联系你的产品供应商 " & _
"错误信息:" & vbCrLf & vbCrLf & _
"错误号 #" & OldErrNum & vbCrLf & _
OldErrDesc
If Not IsNull(strInput1) Then
strMsg = strMsg & vbCrLf & strInput1
End If
If Not IsNull(strInput2) Then
strMsg = strMsg & vbCrLf & strInput2
End If
If Not IsNull(strInput3) Then
strMsg = strMsg & vbCrLf & strInput3
End If
MsgBox strMsg
End
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -