Results 1 to 7 of 7

Thread: Trapping Errors [RESOLVED]

  1. #1

    Thread Starter
    Fanatic Member TheVader's Avatar
    Join Date
    Oct 2002
    Location
    Rotterdam, the Netherlands
    Posts
    871

    Angry Trapping Errors [RESOLVED]

    Why isn't my error trapped? I've built a code which uses two loops. Since I don't have good conditions to restrict the number of loops I use error trapping for it. But I still get errors that stop the execution of the app (5 - Invalid procedure call or argument) although the line above the one that causes the error is 'On Error Goto EndTags'...

    The code follows this format. If this doesn't help I'll post my code. Thanks.
    VB Code:
    1. Do
    2.   On Error Goto EndTags
    3.  
    4.   If ...
    5.  
    6.     On Error Goto EndAttributes
    7.     Do
    8.  
    9.     Loop
    10.  
    11.   EndAttributes:
    12.   End If
    13. Loop
    14.  
    15. EndTags:
    Last edited by TheVader; Dec 11th, 2003 at 06:29 PM.
    Author for Visual Basic Web Magazine

    My articles on the Web Browser Control:
    Using the Web Browser Control & Using the DHTML Document Object Model

    The examples referenced in the articles can be found here:

  2. #2
    Addicted Member
    Join Date
    Jul 2000
    Location
    FeedMeTown, Ohio
    Posts
    176
    Hope this helps

    Check under Options and the General Tab. Make sure you have your setting set to "Break on un-Handled errors".

  3. #3
    Super Moderator Shaggy Hiker's Avatar
    Join Date
    Aug 2002
    Location
    Idaho
    Posts
    40,109
    What you have there won't work. Once you raise the first error and go to end attributes, you remain in that error handler. A second error won't take you to the next point, it will just cause an error. You must leave the error handler before entering another one. You need a resume, Resume Next, or exit sub somewhere in there, or a second error won't be handled.

  4. #4

  5. #5
    Super Moderator Shaggy Hiker's Avatar
    Join Date
    Aug 2002
    Location
    Idaho
    Posts
    40,109
    I wasn't going to go there, but using an error handler to terminate a loop is a little odd.

  6. #6

  7. #7

    Thread Starter
    Fanatic Member TheVader's Avatar
    Join Date
    Oct 2002
    Location
    Rotterdam, the Netherlands
    Posts
    871
    Thanks for the info Hiker, I didn't know two labels couldn't be handled at the same time. But indeed, ending a loop with error handling is a little harsh. I looked into it again and I found another way to restrict one of the loops. Thanks guys.
    Author for Visual Basic Web Magazine

    My articles on the Web Browser Control:
    Using the Web Browser Control & Using the DHTML Document Object Model

    The examples referenced in the articles can be found here:

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