+ Reply to Thread
Results 1 to 3 of 3

2 Stop Timers on User Form

  1. #1
    Registered User
    Join Date
    09-22-2014
    Location
    India
    MS-Off Ver
    2003
    Posts
    7

    Unhappy 2 Stop Timers on User Form

    Hi All,

    I am trying to insert 2 stop timers on my VBA user form... One is to show login hours and other one to show break hours.
    My 1st timer is working well until I click a command button to activate 2nd timer to count break time. This command freeze 1st timer and now second timer doesn’t stop and behaves like 1st timer.
    I want to know if it’s possible to work two timers on same form. If yes how do I code that to insure one timer code does not interrupt the other one. I need timer one to be continuous and 2nd to start with last end time when started again.

    My current code goes as:

    Please Login or Register  to view this content.
    Last edited by JBeaucaire; 09-22-2014 at 01:45 PM. Reason: Added missing CODE tags. Please read and follow the Forum Rules, link above in the menu bar. Thanks.

  2. #2
    Forum Expert
    Join Date
    01-23-2013
    Location
    USA
    MS-Off Ver
    Microsoft 365 aka Office 365
    Posts
    3,863

    Re: 2 Stop Timers on User Form

    Hi VJOSHI,

    Try the following code, which is also in the attached file.

    There are global variables in the Ordinary Code module that store:
    a. If the specific timer is enabled
    b. The Start Time for that timer

    I changed the storage type to Double for the Timers, because that seems to be the data type that is usually used. My personal coding style is to put as little code in the UserForm module as possible, because it seems to be a lot easier for me to debug.

    My UserForm has the following control names that are used by the code:
    a. LabelTimer1 - Timer1 display
    b. LabelTimer2 - Timer2 display
    c. CommandButton1 - Starts Timer2
    d. CommandButton2 - Stops Timer2
    e. CommandButton3 - Resets Timer2


    UserForm1 module code:
    Please Login or Register  to view this content.

    Ordinary module code (such as Module1):
    Please Login or Register  to view this content.
    I hope this helps.

    Lewis
    Attached Files Attached Files

  3. #3
    Registered User
    Join Date
    09-22-2014
    Location
    India
    MS-Off Ver
    2003
    Posts
    7

    Re: 2 Stop Timers on User Form

    Hi Lewis,

    Thanks for this instant help. With little tweaks as per my requirement your code is working great.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] User Form to execute search and return all values to the user form for editing
    By allwrighty in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 05-11-2013, 10:40 PM
  2. [SOLVED] Excel vba user form- open directly to user form not worksheet
    By PANTECH in forum Excel Programming / VBA / Macros
    Replies: 26
    Last Post: 04-24-2013, 05:07 PM
  3. [SOLVED] Excel user form- If/Then statement outcome to show on user form
    By PANTECH in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 04-18-2013, 09:16 AM
  4. Userform - stop user saving or closing form is not complete
    By denise6372 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 09-18-2012, 12:24 AM
  5. calculating multiple stop/start timers within a cell
    By kmfdm515 in forum Excel Programming / VBA / Macros
    Replies: 13
    Last Post: 01-24-2011, 02:20 PM

Tags for this Thread

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