Question Create Time Clock Button?

vss

Registered User.
Local time
Today, 08:47
Joined
Nov 27, 2008
Messages
11
Hi all,

I want to create a toggle button (On/Off), that can show time clock on button. Click to start time, click again to stop time.

Thank for help.
 
do you want the time to update or just show the time when toggled? Do you want actual time or a timer/countdown?
 
do you want the time to update or just show the time when toggled? Do you want actual time or a timer/countdown?

I want to show time on button caption. Toggle start and stop time clock. (actual time)
 
I think you have misunderstood my question. However....


To show the current time:
Set the caption initially as Start then use this code
Code:
If Not Toggle2 Then
    Toggle2.Caption = "Start"
Else
    Toggle2.Caption = Time()
End If
You will also need to use the Forms OnTimer event to keep the time current
Code:
Private Sub Form_Timer()
If Toggle2.Caption <> "Start" Then Toggle2.Caption = Time()
End Sub

To show a stopwatch effect (elapsed time):
Declare a Public variable to hold the time the timer was started, then use this code
Code:
If Not Toggle3 Then
    Toggle3.Caption = "Start"
Else
    ToggleStart = Time()
    Toggle3.Caption = Format(Time() - ToggleStart, "hh:mm:ss")
End If
Again you will need to use the Forms OnTimer event to keep the elapsed time up to date
Code:
Private Sub Form_Timer()
If Toggle3.Caption <> "Start" Then Toggle3.Caption = Format(Time() - ToggleStart, "hh:mm:ss")
End Sub
 

Users who are viewing this thread

Back
Top Bottom