+ Reply to Thread
Results 1 to 2 of 2

Aborting code execution

  1. #1
    Registered User
    Join Date
    04-29-2011
    Location
    Europe
    MS-Off Ver
    Excel 2007
    Posts
    22

    Aborting code execution

    Hello,

    What I have is a userform with a number of command buttons and a label. Whenever the user moves the mouse over one of the buttons, the caption of the label is updated to display a description of that button's function. This is done in an "animated" fashion, generating the caption one character at a time, using the following code:

    Please Login or Register  to view this content.


    The problem with this code is revealed when the user moves the mouse over a button while the description for another button is still being generated on screen. Because of the DoEvents statement, the MouseMove event for the second button will fire, and the AnimateText routine will start showing the corresponding description instead. So far, so good. However, once this second instance of the AnimateText routine has run its course, the original instance, which was interrupted by the MouseMove event, is resumed.

    To illustrate:

    Say there are three buttons, with as descriptions "first", "second" and "third":

    f (mouse over button 1)
    fi
    fir
    s (mouse over button 2)
    se
    sec
    seco
    t (mouse over button 3)
    th
    thi
    thir
    third
    secon (this is where it goes wrong)
    second
    firs
    first
    The question: Is there a way to abort the execution of a subroutine when a new event is triggered, rather than merely suspending it?

    Thanks in advance for any advice!

    Kind regards,

    nymm
    Last edited by nymm; 05-12-2011 at 04:54 AM.

  2. #2
    Registered User
    Join Date
    04-29-2011
    Location
    Europe
    MS-Off Ver
    Excel 2007
    Posts
    22

    Re: Aborting code execution

    Never mind, I found a solution:

    Please Login or Register  to view this content.

+ 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