Results 1 to 4 of 4
  1. #1
    Join Date
    Sep 2003
    Posts
    102

    Unanswered: Runtime errors in VBA

    Hi,
    is there any possible way to catch runtime errors like one does in C ?

    For example, if I have a "timeout error", would it be possible to have the code continue on ?


    Thanks

  2. #2
    Join Date
    Jul 2003
    Location
    Amsterdam, Nederland
    Posts
    450

    Question is this what your looking for ?

    set this at the top of your code

    ON error resume next

  3. #3
    Join Date
    Oct 2003
    Posts
    706

    Red face Re: Runtime errors in VBA

    [i]
    is there any possible way to catch runtime errors like one does in C ?
    For example, if I have a "timeout error", would it be possible to have the code continue on ?
    Well, "this is Basic, not a real language and not even really Basic."

    {Oops! $DEFINE TOMATO_PROOF_SUIT ON!}

    It does have exception-trapping after a sort, in the "On Error" and "Resume" statements, but it's piss-poor (ahem) compared to C's "throw" and "catch." (Or Delphi's "try.")
    ChimneySweep(R): fast, automatic
    table repair at a click of the
    mouse! http://www.sundialservices.com

  4. #4
    Join Date
    Jul 2003
    Location
    Amsterdam, Nederland
    Posts
    450

    Thumbs up clean error trap

    Public sub .....
    On Error GoTo errhand:
    dim x

    x=y

    errhand:
    msgbox "There's an error " & vbcrlf & err.no & ": " & Err.Description
    ' what you can do here is up to you or exit or continue
    Err = 0
    resume next

    End Sub

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •