Consulting

Results 1 to 10 of 10

Thread: Solved: Another countdown query

  1. #1
    VBAX Regular
    Joined
    Feb 2007
    Posts
    35
    Location

    Solved: Another countdown query

    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

    [VBA] 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[/VBA]

  2. #2
    Moderator VBAX Sage SamT's Avatar
    Joined
    Oct 2006
    Location
    Near Columbia
    Posts
    7,814
    Location
    Quote Originally Posted by ukyank
    I was hoping to make it look like a timer
    What do you mean by "like a timer?"
    I expect the student to do their homework and find all the errrors I leeve in.


    Please take the time to read the Forum FAQ

  3. #3
    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.
    Attached Files Attached Files

  4. #4
    Moderator VBAX Sage SamT's Avatar
    Joined
    Oct 2006
    Location
    Near Columbia
    Posts
    7,814
    Location
    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

    [vba]UserForm1.DisplayTime = Countdowntime[/vba]
    I expect the student to do their homework and find all the errrors I leeve in.


    Please take the time to read the Forum FAQ

  5. #5
    VBAX Regular
    Joined
    Feb 2007
    Posts
    35
    Location
    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.

  6. #6
    Moderator VBAX Sage SamT's Avatar
    Joined
    Oct 2006
    Location
    Near Columbia
    Posts
    7,814
    Location
    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.
    Attached Files Attached Files
    I expect the student to do their homework and find all the errrors I leeve in.


    Please take the time to read the Forum FAQ

  7. #7
    VBAX Regular
    Joined
    Feb 2007
    Posts
    35
    Location
    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:


    [vba]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[/vba]

  8. #8
    Moderator VBAX Sage SamT's Avatar
    Joined
    Oct 2006
    Location
    Near Columbia
    Posts
    7,814
    Location
    [VBA]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
    [/VBA]
    I expect the student to do their homework and find all the errrors I leeve in.


    Please take the time to read the Forum FAQ

  9. #9
    VBAX Regular
    Joined
    Feb 2007
    Posts
    35
    Location
    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 ;-)

  10. #10
    Moderator VBAX Sage SamT's Avatar
    Joined
    Oct 2006
    Location
    Near Columbia
    Posts
    7,814
    Location


    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.

    [vba]Const MSSecondFactor As Double = 0.000011574 '1 second[/vba]

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

    Boy! Was I ever wrong.
    Last edited by SamT; 04-03-2013 at 09:22 AM.
    I expect the student to do their homework and find all the errrors I leeve in.


    Please take the time to read the Forum FAQ

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •