|
-
Jul 19th, 2000, 01:48 PM
#1
Thread Starter
Lively Member
I have a sub called WriteError that writes an error out to a log file. Is there any way to get a sub to On Error Goto ErrorTrap (where it writes the error to file) and then Resume Next?
If I put Resume Next in my Error Trap routine will it jump back up in the code and start where it left off?
Thanks for any help!
Kevin
VB6 w/SP4
-
Jul 19th, 2000, 01:56 PM
#2
Addicted Member
Simply put...
-
Jul 19th, 2000, 01:57 PM
#3
Resuem the execution at same line that caused the error.
Code:
On Error Goto ErrorTrap
'code
ErrorTrap:
Open App.path & "\error.log" For Output As #1 'or append if you want to save the log file continously
Print #1, Error
Close #1
Resume
-
Jul 19th, 2000, 05:55 PM
#4
You can reset the internal error variable
FYI
Err = 0 resets the error variable to avoid any unpleasantness down the line. Just thought l would mention it as something to look at
-
Jul 19th, 2000, 06:15 PM
#5
Fanatic Member
Write your error to the logfile AS SOON AS you enter the error handler, alternatively send it to a procedure to do just that.
I guess the first option is the best as:
A: if the error is recoverable then you can place code to recover from it (something like -no disk in floppy drive)and then RESUME (to resume at the same line the error occurred) or RESUME NEXT (to resume code execution at the line of code following the line which caused the error.
B: If its not recoverable and the machine is about to freeze (if it not done so already) then at least you wrote the error out so you can analyse why it happened.
DocZaf
{;->
-
Jul 20th, 2000, 12:08 PM
#6
Here's a better way to determine both the error and its number.
Code:
On Error Goto ErrorTrap
'code
ErrorTrap:
Open App.path & "\error.log" For Append As #1
Print #1, Err.Number & " - " & Error$
Close #1
Example:
Code:
On Error Goto ErrorTrap
Error 16
Exit Sub
ErrorTrap:
MsgBox Err.Number & " - " & Error$
Hope that helps.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|