PDA

View Full Version : Solved: Another countdown query



ukyank
04-01-2013, 04:22 AM
Hi all, I've been searching for an answer but none seem to do what I'm looking for or I cant modify what I found. I did get the below but it shows the countdown in number from 10 to 0 I was hoping to make it look like a timer can anyone help?

Thank in Advance

If PPackCall14 = True Then
Dim i As Integer
Select Case lbMinutes.Value
Case ""
MsgBox "No value entered!"
Exit Sub
Case Else
For i = lbMinutes.Value To 0 Step -1
lbCountDown.Caption = i '"Please wait 5 minutes."
Application.Wait (Now + TimeValue("0:00:01"))
NoAnswer.Repaint
Next i
End Select
lbCountDown.Caption = "Make your 2nd attempt now."
'MsgBox "Blast off!!"

End If

SamT
04-01-2013, 10:15 AM
I was hoping to make it look like a timer

What do you mean by "like a timer?"

dannohayes
04-01-2013, 10:39 AM
Here's a countdown timer that I wrote (a long time ago, so don't judge me:). It's got 2 display modes - one is just regular text blown up really big; the other is my attempt at 7-segment numerals. (It was for giving ministers at a conference an allotted time to speak and I was trying to get the numbers bigger so they could see easier.)

Tell me what you think.

SamT
04-01-2013, 11:25 AM
Download and install Fonts from

http://www.fontspace.com/category/led

In the UserForm I added, set TextBox1's Font to the installed font name

Rewrite your coundown code to it's simplest,Use it to Load and Show the UserForm and send the countdown value to the Form's TextBox by

UserForm1.DisplayTime = Countdowntime

ukyank
04-01-2013, 03:00 PM
Cheers for the replies guys, I'll use them to fix my code. I should have written that this is on a Userform and I want it to look like a countdown clock (00:05:00 counting down to 00:00:00) instead of just numbers (300 counting down to 0) as I have it currently.

Dan - dude I would never judge someone else's code and since I'm still new and terrible at this I appreicate anoyone willing to give me guidance.

Sam T - Thanks I probably should have waiting a minute more before posting I was frustrated and I definately didnt write my query clearly.

SamT
04-01-2013, 04:52 PM
My bad too. I DL'ed Dan's book, added a cool form that looked just like a clock and managed to not Upload it.

ukyank
04-02-2013, 12:39 PM
Ugh this is gonna be UGLY but I solved this issue with a work around, doesn't look like the prettiest girl at the ball but she does what's she's supposed too:


Private Sub PPackCall24_Click()
If PPackCall24 = True Then
Dim i As Integer, ii As Integer, iii As String, iv As String

For ii = 10 To 0 Step -1
For i = 60 To 0 Step -1 ' tbMinutes2.Value To 0 Step -1

If i > 9 Then
iii = Str(i)
Else
iii = "0" + Str(i)
End If

If ii > 9 Then
iv = Str(ii)
Else
iv = "0" + Str(ii)
End If
lbCountDown2.Caption = "00:" + iv + ":" + iii
Application.Wait (Now + TimeValue("0:00:01"))
NoAnswer.Repaint
Next i
Next ii

lbCountDown2.Caption = "Make your 3rd attempt now."
End If
End Sub

SamT
04-02-2013, 05:34 PM
Private Sub PPackCall24_Click()
'I HATE LITERALS !!!
If PPackCall24 = True Then
Dim i As Integer
Const MSSecondFactor As Double = 0.000011574 '1 second
Dim CountDownSeconds As Double
Const FString As String = "hh:mm:ss"

CountDownSeconds = 600 '10 minutes

For i = CountDownSeconds To 0 Step -1
lbCountDown2.Caption = Format((i * MSSecondFactor), FString)
Application.Wait (Now + MSSecondFactor)
NoAnswer.Repaint
Next i


lbCountDown2.Caption = "Make your 3rd attempt now."
End If
End Sub

ukyank
04-03-2013, 03:05 AM
SamT - thanks so much for that. Your code is so much more simpler and clear than mine. Ahhh just one think, I omitted the "I Hate Literals" comment. hope the code still runs without it ;-)

SamT
04-03-2013, 08:40 AM
:rofl:

BTW, this is off by a few parts in a thousand, I think MS uses a factor that takes astronomically accurate day lengths into account. I just used a perfect 24 hr day to calculate it.

Const MSSecondFactor As Double = 0.000011574 '1 second

The exact value of 1 second is 0.000,011,574,074,074,074,1.

Boy! Was I ever wrong.