Make your own free website on

Save An Error Log File

'The user encounter errors in your program? do you want to know what errors
'exactly he had? this is the code for you. the error will be saved in a file at your
'program directory.
'Insert the following code to your form:

Public Sub errLogger(ByVal lNum As Long, ByVal sDesc As String, ByVal sFrom As String)
Dim FileNum As Integer
FileNum = FreeFile
Open App.Path & "\Errors.log" For Append As FileNum
Write #FileNum, lNum, sDesc, sFrom, Now()
Close FileNum
End Sub

Private Sub Command1_Click()
On Error GoTo Err_handler
'The code for the Command Click event should be placed right here.
'The line below destined to make an error at your program, so you will be able to see
'the error log file
Command1.Picture = LoadPicture("InvalidFile")
Exit Sub
If Err.Number <> 0 Then
errLogger Err.Number, Err.Description, "Command1_Click"
Resume Next
End If
End Sub

Go Back