August 19, 2009

VB 6.0: Write/Append log in text file

Public Sub ErrorInFile(ModuleName As String, FunctionName As String, ErrorDesc As String)
Dim iFileNumberWrite As Integer, str As String
iFileNumberWrite = FreeFile
str = ""
str = str & "On DateTime : " & Format(Now, "dd-MMM-yyyy HH:mm:ss") & vbCrLf
str = str & "Module Name : " & ModuleName & vbCrLf
str = str & "Function Name : " & FunctionName & vbCrLf
str = str & "Error Description : " & ErrorDesc & vbCrLf
str = str & "----------------------------------------------------" & vbCrLf
Open App.Path & "\Error.Log" For Append As iFileNumberWrite
Print #iFileNumberWrite, str
Close #iFileNumberWrite
End Sub

No comments:

Post a Comment