+ Reply to Thread
Results 1 to 3 of 3

Why is my click event looping 4 times

  1. #1
    Forum Contributor
    Join Date
    03-13-2009
    Location
    New Jersey
    MS-Off Ver
    Excel 2007
    Posts
    136

    Why is my click event looping 4 times

    I have created a program to perform a calculation on data input into a userform. When I click on the "Calculate" button it is supposed to run the calculation and then show the user the result in a message box. When they click "ok" the message box should go away and just leave the form showing. For some reason, when I click on "ok" it loops back through the click event handler again and shows the message box with the result again. It does this 4 times before finally going away for good. Is there some easy reason why this might be happening?


    The click event is handled within my class as a Public WithEvents object. The code is:

    Please Login or Register  to view this content.
    Calculatesub is here:

    Please Login or Register  to view this content.

  2. #2
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    England
    MS-Off Ver
    365, varying versions/builds
    Posts
    22,015

    Re: Why is my click event looping 4 times

    I can't see anything in the Calculatesub code, so I'd guess it has to do with how your class is related to the userform and its controls.
    Everyone who confuses correlation and causation ends up dead.

  3. #3
    Forum Contributor
    Join Date
    03-13-2009
    Location
    New Jersey
    MS-Off Ver
    Excel 2007
    Posts
    136

    Re: Why is my click event looping 4 times

    That must be the problem. I am adding the control to every instance of the class that gets created.

+ 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