+ Reply to Thread
Results 1 to 4 of 4

Error handling for error that occurs frequently

  1. #1
    Registered User
    Join Date
    07-15-2008
    Location
    germany
    Posts
    56

    Error handling for error that occurs frequently

    Hi Experts,

    I wonder since yesterday, whether there is a way to handle error that occurs many times.

    For example the following code go into error handling when first time a number is divided with 0, the other nine time it throws vba run time error. Is there a way that the code go into error handler the other nine time also ?
    PHP Code: 

    sub test
    ()

    dim i as integer

    on error 
    goto myerror

    for 1 to 10

    debug
    .print i/0

    next i

    myerror
    :

    msgbox "You tried to divide by zero"

    end sub 
    Last edited by adyan76; 02-15-2010 at 02:54 PM.

  2. #2
    Forum Expert
    Join Date
    06-25-2009
    Location
    Sofia, Bulgaria, EU
    MS-Off Ver
    Excel 2003-2013
    Posts
    1,290

    Re: Error handling for error that occurs frequently

    Hi,
    I don't understand your question. as it is now it there will be just one error - the first time, after that it will go to the error handler and show msg. after that sub will end. There will be no nine more errors
    If you are pleased with a member's answer then use the Star icon to rate it.

  3. #3
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: Error handling for error that occurs frequently

    I agree w/ Buran, but you should have an Exit Sub after the Next i.

    Please change your PHP tags to CODE tags.
    Entia non sunt multiplicanda sine necessitate

  4. #4
    Valued Forum Contributor tony h's Avatar
    Join Date
    03-14-2005
    Location
    England: London and Lincolnshire
    Posts
    1,187

    Re: Error handling for error that occurs frequently

    Please Login or Register  to view this content.


    click on the * Add Reputation if this was useful or entertaining.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1