[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 123
  • Last Modified:

Funtion for making an error log

I'm fairly new to VB front end.  We are using VB 6.0 on a Sql Server.  I have been tasked to create a function to log all error messages, including date, time, screen, message, activity etc.

Would anyone be able to help me come up with an algorithm to do this?

-A
0
ambulance
Asked:
ambulance
  • 2
  • 2
1 Solution
 
Éric MoreauSenior .Net ConsultantCommented:
You can have a generic routine that will log errors but this sub will have to called from each error trapping in each sub of your application.

So a normal sub will look like this:

private sub MySub()
on error goto eh
   'the code of your sub here
exit sub

eh:
   call LogError(err,"MySub")
End Sub

Somewhere in a standard module:
Public sub LogError(pErr, pSource)
'you can do what ever you want here with the error
end sub
0
 
ambulanceAuthor Commented:
Okay, this will work.  At first I wasn't sure if placing that in 500+ error traps would be feasible, but yes it is.  

Now, one more quick question.  (If you don't mind, that is)  I need to open a text file, pass in the app.path (application path) and then the error log is to display a list of all errors received throughout the testing phase of this project.

What I need help with here, is just how to open the text file, and pass in the app.path.  I think I can figure out how to get it to display the log....

Thanks again
-A
0
 
Éric MoreauSenior .Net ConsultantCommented:
Use this:

Open "Test.txt" For Output As #1
Print #1, "This is a test!!!"
Print #1, "This is a test!!!"
Print #1, "This is a test!!!"
Print #1, "This is a test!!!"
Close #1
0
 
ambulanceAuthor Commented:
thanks.  Ithink I have it figured out.
-A
0

Featured Post

Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now