'****************************************日志記錄*****************Start***************************************************************
Public Function openLogfile()
Dim F As String
' nStr = Format(Now, "yyyy-mm-dd hh:mm:ss") & nStr
F = App.Path & "\log\" & Format(Now, "yyyymmddhhmmss") & ".log"
'如果要將檔案保存到與你的 exe 相同的檔案夾,將上句改為 F = App.Path & "\myprog.log"
H = FreeFile
On Error Resume Next
Open F For Append As #H
End Function
Public Function MyLog(nStr As String)
Print #H, Format(Now, "yyyy-mm-dd hh:mm:ss")
Print #H, nStr
End Function
Public Function logfileClose()
Close #H
Set H = Nothing
Set log = Nothing '釋放日志記錄變數
End Function
Public Sub FS_WriteTxtFile(AFName As String, ATxt As String)
On Error GoTo Err0:
'寫文本檔案
Dim WF, WFS
Set WFS = CreateObject("Scripting.FileSystemObject")
Set WF = WFS.OpenTextFile(AFName, 8, True)
WF.WriteLine ATxt
WF.Close
Exit Sub
Err0:
MsgBox "寫文本檔案【" & AFName & "】時遇到錯誤!" & vbCrLf & Err.Description, , "系統提示"
End Sub