Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here


Time Counter/Stop watch

Time Counter/Stop watch

Time Counter/Stop watch

Please can somebody help me?

I need to build a time counter in short-time with a button to stop and start the time.

The time counter would count up from 00:00 up to say 99:59?

Please can someone advise?

RE: Time Counter/Stop watch


Try this:

(I will put the names I have used in brackets).

Create a label on the form (lblDisplay). Create a Start/Stop command button (cmdStopStart), and (maybe) a reset command button (cmdReset).

Then add the following code to your form:


Dim datCurrent As Date
Dim blnCount As Boolean

Private Sub cmdReset_Click()
    datCurrent = #00:00#
    lblDisplay.Caption = Format(datCurrent, "Short Time")
End Sub

Private Sub cmdStopStart_Click()
    If Not blnCount Then
        cmdStopStart.Caption = "Stop"
        cmdStopStart.Caption = "Start"
    End If
    blnCount = Not blnCount
End Sub

Private Sub Form_Timer()
    If blnCount Then
        datCurrent = DateAdd("n", 1, datCurrent)
        lblDisplay.Caption = Format(datCurrent, "Short Time")
    End If
End Sub

Set the Timer Interval on the Forms property sheet on the events tab to 60000, so it will fire once every 60 secs.

For added effect you could set the label controls properties (on property sheet) to make it look like a real clock:

Caption - 00:00
Fore Color - 65280
Back Color - 0
Text Align - Center
Special Effect - Sunken

Hope I haven't forgotten anything.
Good luck,


RE: Time Counter/Stop watch

cheers for the code Dean, but there is a problem!

The Timer does not start for some reason?

Can you help?

RE: Time Counter/Stop watch

In the OnTimer event, do you have [Event Procedure] selected in the property sheet for the form.

RE: Time Counter/Stop watch

Yeah i do?


any help?

RE: Time Counter/Stop watch

I just forgot to explicitly mention setting that in my original post and thought you may not have...

Anyway, is it still not working then? You definitely have the Timer Interval Set to 60000?

Actually, when I tested this I included seconds which made it more obvious that the timer was running. You said you wanted the time in a Short-Time format. So the above set up only counts minutes. Maybe you wanted seconds and minutes?

If so, make the following changes to these functions:


Private Sub cmdReset_Click()
    datCurrent = #00:00:00#
    lblDisplay.Caption = Format(datCurrent, "Long Time")
End Sub

Private Sub Form_Timer()
    If blnCount Then
        datCurrent = DateAdd("s", 1, datCurrent)
        lblDisplay.Caption = Format(datCurrent, "Long Time")
    End If
End Sub
Also Change the Timer Interval to 1000 and the original caption of the display label to "00:00:00".

Maybe that's what you wanted - I thought it was a bit strange you didn't want seconds on it.


Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close