+ Reply to Thread
Results 1 to 3 of 3

On Error GoTo ... But wait!

Hybrid View

Guest On Error GoTo ... But wait! 04-28-2006, 12:25 PM
Guest RE: On Error GoTo ... But... 04-28-2006, 12:40 PM
Guest RE: On Error GoTo ... But... 04-29-2006, 09:45 PM
  1. #1
    monir
    Guest

    On Error GoTo ... But wait!

    Hello;
    Here's a simple illustration:
    -------------------------------------------------------
    Sub Test_1()
    On Error GoTo myErrorHandler
    For MyIndex = 1 To 40
    ....myCode1
    Next myIndex
    ....myCode2
    Exit Sub

    myErrorHandler:
    MsgBox "The non-linear multi-variant algorithm failed ..."
    End Sub
    --------------------------------------------------------
    I would like to clear (or suppress) the Err object, if any run-time error
    occurs within the For loops, until the For loops are complete.
    If there's a run-time error for the current value of myIndex, then move to
    the next value of myIndex.
    If there's at least one error-free loop at the end of the For ... Next, then
    ignor any run-time error(s) which might have been encountered and resume
    next.
    If there is no viable solution (i.e.; no error-free loop at the end of the
    For ... Next), then GoTo myErrorHandler.

    Could someone please show how-to accomplish that?
    You might prefer to put the procedure in a separate routine to be called
    from within the For ... Next.

    Thank you kindly.

  2. #2
    Tom Ogilvy
    Guest

    RE: On Error GoTo ... But wait!

    Sub Test_1()
    On Error Resume Next
    cnt = 0
    For myIndex = 1 To 40

    ' your code

    ' just before the next
    If Err.Number <> 0 Then
    cnt = cnt + 1
    Err.Clear
    End If
    Next myIndex
    If cnt = 40 Then GoTo myErrorHandler
    ' ....myCode2
    Exit Sub

    myErrorHandler:
    MsgBox "The non-linear multi-variant algorithm failed ..."
    End Sub

    --
    Regards,
    Tom Ogilvy


    "monir" wrote:

    > Hello;
    > Here's a simple illustration:
    > -------------------------------------------------------
    > Sub Test_1()
    > On Error GoTo myErrorHandler
    > For MyIndex = 1 To 40
    > ....myCode1
    > Next myIndex
    > ....myCode2
    > Exit Sub
    >
    > myErrorHandler:
    > MsgBox "The non-linear multi-variant algorithm failed ..."
    > End Sub
    > --------------------------------------------------------
    > I would like to clear (or suppress) the Err object, if any run-time error
    > occurs within the For loops, until the For loops are complete.
    > If there's a run-time error for the current value of myIndex, then move to
    > the next value of myIndex.
    > If there's at least one error-free loop at the end of the For ... Next, then
    > ignor any run-time error(s) which might have been encountered and resume
    > next.
    > If there is no viable solution (i.e.; no error-free loop at the end of the
    > For ... Next), then GoTo myErrorHandler.
    >
    > Could someone please show how-to accomplish that?
    > You might prefer to put the procedure in a separate routine to be called
    > from within the For ... Next.
    >
    > Thank you kindly.


  3. #3
    monir
    Guest

    RE: On Error GoTo ... But wait!

    Tom;
    Absolutely perfect!
    Thank you very much fpr your help.


    "Tom Ogilvy" wrote:

    > Sub Test_1()
    > On Error Resume Next
    > cnt = 0
    > For myIndex = 1 To 40
    >
    > ' your code
    >
    > ' just before the next
    > If Err.Number <> 0 Then
    > cnt = cnt + 1
    > Err.Clear
    > End If
    > Next myIndex
    > If cnt = 40 Then GoTo myErrorHandler
    > ' ....myCode2
    > Exit Sub
    >
    > myErrorHandler:
    > MsgBox "The non-linear multi-variant algorithm failed ..."
    > End Sub
    >
    > --
    > Regards,
    > Tom Ogilvy
    >
    >
    > "monir" wrote:
    >
    > > Hello;
    > > Here's a simple illustration:
    > > -------------------------------------------------------
    > > Sub Test_1()
    > > On Error GoTo myErrorHandler
    > > For MyIndex = 1 To 40
    > > ....myCode1
    > > Next myIndex
    > > ....myCode2
    > > Exit Sub
    > >
    > > myErrorHandler:
    > > MsgBox "The non-linear multi-variant algorithm failed ..."
    > > End Sub
    > > --------------------------------------------------------
    > > I would like to clear (or suppress) the Err object, if any run-time error
    > > occurs within the For loops, until the For loops are complete.
    > > If there's a run-time error for the current value of myIndex, then move to
    > > the next value of myIndex.
    > > If there's at least one error-free loop at the end of the For ... Next, then
    > > ignor any run-time error(s) which might have been encountered and resume
    > > next.
    > > If there is no viable solution (i.e.; no error-free loop at the end of the
    > > For ... Next), then GoTo myErrorHandler.
    > >
    > > Could someone please show how-to accomplish that?
    > > You might prefer to put the procedure in a separate routine to be called
    > > from within the For ... Next.
    > >
    > > Thank you kindly.


+ 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