Results 1 to 10 of 20

Thread: HTML Code Test --post8798

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #15
    Fuhrer, Vierte Reich DocAElstein's Avatar
    Join Date
    Aug 2014
    Posts
    9,521
    Rep Power
    10
    Still in IE 9

    Sub TestEvaluateVBA1b_n1n2n3()
    Range("H2") = Evaluate("**" & Range("B2").Address & "&""****""&" & Range("C2").Address & "&""****""&" & Range("D2").Address & "")
    End Sub


    Error Handling statement Resumes
    On Error Resume Next

    The next posts will look at the second main Error handling statement , On Error Resume Next .
    I will look at this in a similar way as the ideas in the last two posts: I will initially discus the more fundamental general idea of the Resume .
    Building on that, I will derive user defined error handlers that works in a similar way.

    In my opinion the whole VBA error handling is an unintuitive mess. In the unlikely event that you have read and understood most of my previous ramblings, then a couple logical conclusion might be the following:

    _ We might reasonably guess that there is no On Error Resume
    This is because that would imply that at an error the code tries again. And again. And again And again. And again.. … Conceivable there might be a situation where that might work if some external influence meant that the code line erroring suddenly didn’t. But that is unlikely. More likely is that having such an option would cause the attempt at an infinite loop or retrying.
    In fact that assumption is correct. There is no On Error Resume

    _ We might reasonably guess that there might be a On Error Resume LabelOrLineNumber
    That would be a reasonable thing to do – always to go to a specific point with the exception cleared. There is not that option. There is no On Error Resume LabelOrLineNumber I don’t know why. It might not be too dangerous a thing to have. It might be quite useful. Never mind.

    _ What might be quite dangerous is to have something that just keeps going like a blind dumb Bull in a China shop making no account of any errors that occur.
    Such a thing would logically go under the command statement of On Error Resume Next
    Well we have one. It almost does what would logically be expected: The main diversion from logic is that the Err object still has information about the last error.

    On Error Resume Next
    The last bit of illogic will at least make for an interesting attempt to mimic this handler. It will mean that we have some good practice at using the Err object, as we will need to fill it after other things we use, such as the On Error GoTo -1 have emptied it!

    Pseudo On Error Resume Next
    In the first instance, the code is very similar to that for the Pseudo Resume Next
    It just means that we are considering the initial On Error GoTo LabelOrLineNumber as part of the “hidden internal” coding that we are trying to imitate. (In the case of all the 3 resumes an initial On Error GoTo LabelOrLineNumber was necessary as they won’t work without one, but it was not an integral part of them, as it is in the VBA On Error Resume Next statement )
    In addition we must add some coding to refill the Err object.
    As the final real On Error Resume Next is a single line we would not have the ability to do any changes after the error, so our mimicking code will only concentrate on
    _ organising that the code continues after an error in normal run mode ( not in exceptional erections ) and also
    _ the Err object must contain information about the last error.

    The first requirement is already fulfilled in with our previous code for the pseudo Resume Next.
    The code below follows closely that previous code.
    It has the part removed that “does something” to effect the outcome of an error
    The code demonstrates that we have information available about the error that occurred. This is accessed just after the code continues from the line below that which errored. In typical applications, where the error handler On Error Resume Next is used, a check on the Err object number or description is used to determine if an error occurred
    Note: we can do this On Error Resume Next at any point even after the On Error Resume Next has been used, as the exception is cleared by On Error Resume Next
    If you must use On Error GoTo 0 then it is good practice as soon as possible after to use On Error GoTo 0 as soon as possible after.

    Code for pseudo On Error Resume Next in next post
    Last edited by DocAElstein; 03-20-2018 at 06:38 PM.

Similar Threads

  1. Replies: 5
    Last Post: 06-10-2019, 10:14 PM
  2. This is a test Test Let it be
    By Admin in forum Test Area
    Replies: 6
    Last Post: 05-30-2014, 09:44 AM
  3. change table top row to a different colour with html code
    By peter renton in forum Excel Help
    Replies: 2
    Last Post: 02-17-2014, 08:08 PM
  4. Test
    By Excel Fox in forum Den Of The Fox
    Replies: 0
    Last Post: 07-31-2013, 08:15 AM
  5. Test
    By Excel Fox in forum Word Help
    Replies: 0
    Last Post: 07-05-2011, 01:51 AM

Posting Permissions

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