V vss Registered User. Local time Today, 08:47 Joined Nov 27, 2008 Messages 11 Aug 21, 2012 #1 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.
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.
Isskint Slowly Developing Local time Today, 16:47 Joined Apr 25, 2012 Messages 1,302 Aug 21, 2012 #2 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?
V vss Registered User. Local time Today, 08:47 Joined Nov 27, 2008 Messages 11 Aug 21, 2012 #3 Isskint said: do you want the time to update or just show the time when toggled? Do you want actual time or a timer/countdown? Click to expand... I want to show time on button caption. Toggle start and stop time clock. (actual time)
Isskint said: do you want the time to update or just show the time when toggled? Do you want actual time or a timer/countdown? Click to expand... I want to show time on button caption. Toggle start and stop time clock. (actual time)
Isskint Slowly Developing Local time Today, 16:47 Joined Apr 25, 2012 Messages 1,302 Aug 21, 2012 #4 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
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
V vss Registered User. Local time Today, 08:47 Joined Nov 27, 2008 Messages 11 Aug 21, 2012 #5 Perfect guide, thanks