cErrorLog.cls
资源名称:IE_VB.rar [点击查看]
上传用户:davilee3
上传日期:2015-04-22
资源大小:986k
文件大小:2k
源码类别:
浏览器
开发平台:
Visual Basic
- VERSION 1.0 CLASS
- BEGIN
- MultiUse = -1 'True
- Persistable = 0 'NotPersistable
- DataBindingBehavior = 0 'vbNone
- DataSourceBehavior = 0 'vbNone
- MTSTransactionMode = 0 'NotAnMTSObject
- END
- Attribute VB_Name = "cErrorLog"
- Attribute VB_GlobalNameSpace = False
- Attribute VB_Creatable = True
- Attribute VB_PredeclaredId = False
- Attribute VB_Exposed = False
- Attribute VB_Ext_KEY = "SavedWithClassBuilder6" ,"Yes"
- Attribute VB_Ext_KEY = "Top_Level" ,"Yes"
- Option Explicit
- Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long
- Private Const SW_SHOWNORMAL = 1
- 'local variable(s) to hold property value(s)
- Private mvarLogFile As String 'local copy
- Public Property Let LogFile(ByVal vData As String)
- 'used when assigning a value to the property, on the left side of an assignment.
- 'Syntax: X.LogFile = 5
- mvarLogFile = vData
- End Property
- Public Property Get LogFile() As String
- 'used when retrieving value of a property, on the right side of an assignment.
- 'Syntax: Debug.Print X.LogFile
- LogFile = mvarLogFile
- End Property
- Public Sub AddLog(ByVal nLog As String, Optional AddTime As Boolean = True)
- nLog = Replace(nLog, Chr(13), " ")
- nLog = Replace(nLog, Chr(10), " ")
- If AddTime Then
- nLog = Now & Chr(9) & nLog
- End If
- Debug.Print nLog
- Call WriteLog(mvarLogFile, nLog)
- 'Call DrawScreen
- End Sub
- Public Sub ShowLog(Optional nFileName As String = "")
- On Error Resume Next
- ShellExecute 0&, vbNullString, mvarLogFile, vbNullString, vbNullString, SW_SHOWNORMAL
- End Sub
- Private Sub WriteLog(nfile As String, nLog As String)
- On Error Resume Next
- Dim nFN As Long
- nFN = FreeFile
- Open nfile For Append As nFN
- Print #nFN, nLog
- Close nFN
- End Sub
- 'Private Sub DrawScreen()
- 'Dim tRc As RECT
- 'tRc.Top = 300
- 'tRc.Right = 400
- 'tRc.Bottom = 600
- '
- 'DrawText GetDC(0), "haah", -1, tRc, DT_BOTTOM + DT_RIGHT
- 'End Sub