Results 1 to 6 of 6

Thread: Resume Next

  1. #1

    Thread Starter
    Lively Member
    Join Date
    May 2000
    Location
    Atlanta, GA
    Posts
    80

    Question

    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

  2. #2
    Addicted Member
    Join Date
    Oct 1999
    Location
    Brossard, Québec, Canada
    Posts
    241

    Exclamation Simply put...

    Yes it will!

  3. #3
    Guest
    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

  4. #4
    Guest

    Thumbs up 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

  5. #5
    Fanatic Member
    Join Date
    Jan 1999
    Location
    UK
    Posts
    554
    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
    {;->

  6. #6
    Guest
    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
  •  



Click Here to Expand Forum to Full Width