PC Review


Reply
Thread Tools Rate Thread

Count Timer Pause and Stop button

 
 
baha17@gmail.com
Guest
Posts: n/a
 
      12th May 2010
Hello Everyone,
I am trying to build a count timer on userform. I found a code and
tried to modify as my need which will be as below. I cannot find the
way to put pause the counter timer and stop counter timer. So I need
two more button on my userform. Can anyone give me a hand on that.
Whatever I did did not work to pause the counter or stop the counter.
Thanks in advance,
have a good day
Baha

Here is the code

Option Explicit
Private dTimerEnd As Date
Dim iSecondsLeft, iSecondsLeft1 As Integer

Sub StartTimer()
Dim iSeconds, iSeconds1 As Integer
iSeconds = 10
dTimerEnd = Now + TimeSerial(0, 0, iSeconds)
UserForm1.Label1 = iSeconds
If UserForm1.Label1.Caption = "10" Then
UserForm1.Label1.Caption = "00"
End If
Application.OnTime EarliestTime:=Now + TimeValue("00:00:01"), _
procedure:="CountDown"
End Sub

Sub CountDown()
iSecondsLeft = CInt((dTimerEnd - Now) * 86400)
If iSecondsLeft < 0 Then iSecondsLeft = 0
UserForm1.Label1 = iSecondsLeft
If iSecondsLeft = 0 Then
UserForm1.Label2 = UserForm1.Label2 - 1
StartTimer
End If
If iSecondsLeft > 0 Then
Application.OnTime EarliestTime:=Now + TimeValue("00:00:01"), _
procedure:="CountDown"
End If
If UserForm1.Label2 = 0 Then
'UserForm1.Label2 = "00"
UserForm1.Label2 = 20
UserForm1.Label3 = UserForm1.Label3 * 2
UserForm1.Label4 = UserForm1.Label4 * 2
StartTimer
End If

If Len(UserForm1.Label1) < 2 Then
UserForm1.Label1.Caption = "0" & UserForm1.Label1
End If
If Len(UserForm1.Label2) < 2 Then
UserForm1.Label2.Caption = "0" & UserForm1.Label2
End If
If UserForm1.Label1.Caption = "10" Then
UserForm1.Label1.Caption = "00"
End If
End Sub

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Count Timer Pause and Stop button baha17@gmail.com Microsoft Excel Programming 1 12th May 2010 02:03 PM
Timer w/ Start, Stop, Pause dgold82 Microsoft Excel Programming 2 22nd Apr 2009 10:13 PM
Pause a form that's on a timer? CW Microsoft Access 3 25th Jul 2008 09:00 PM
Stop / Pause a Macro using Pause button scott56hannah Microsoft Excel Programming 4 27th Jun 2008 12:48 PM
How to pause the timer created from System.Threading.Timer class =?Utf-8?B?RGhydXZlc2ggQnJhaG1iaGF0dA==?= Microsoft Dot NET Framework 4 29th Mar 2006 12:05 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 04:35 PM.