PDA

View Full Version : Countdown Timer on Userform



craigos
12-26-2012, 03:39 AM
Hi All,

I am looking for assistance with creating a Countdown time on a Userform.

Now I have searched through many variations on the theme but my requirements I cannot find specifically.

In work we have a forum that we bring tasks to and a specific time is allocated to that task.

I need a UF which has a TextBox where the Chairperson will enter the number of minutes allocated to a specific topic up for discussion, hit the Start button and the timer counts down. (other buttons would be Stop and Reset).

I have an example attached:

Chair inputs whole minutes only i.e. 15 or 20 etc.
The timer in the Textbox should show Minutes and Seconds counting down.
When Time is up I would like a Message Box to show stating time up - as another aid for the Chair as I will be using a Modeless UF that will be running in the Top Right of the screen - for this WB I have kept it in the centre of screen.

Can anyone help or point me in the right direction?

Thanks

Craig

CodeNinja
12-26-2012, 07:16 AM
You could manipulate the time something like this...


Private Sub cbStart_Click()
Dim iSeconds As Integer
Dim dTimeStart As Date
Dim dTimeEnd As Date

dTimeStart = Now
dTimeEnd = Now + ((ufTimer.tbHowLong / 24) / 60)

While Now < dTimeEnd
ufTimer.lbMinutes = Int((dTimeEnd - Now) * 24 * 60)
iSeconds = Int((dTimeEnd - Now) * 24 * 60 * 60)
While iSeconds > 60
iSeconds = iSeconds - 60
Wend
ufTimer.lbSeconds = iSeconds
DoEvents
Wend
End Sub