Results 1 to 9 of 9

Thread: Countdown Timer

  1. #1

    Thread Starter
    New Member
    Join Date
    Feb 2002
    Location
    Lake Zurich, Illinois
    Posts
    4

    Countdown Timer

    I am having some difficulty making a countdown timer that will countdown to March 30, 2003 using days, hours, minutes, and seconds.

  2. #2
    The Devil crptcblade's Avatar
    Join Date
    Aug 2000
    Location
    Quetzalshacatenango
    Posts
    9,091
    Well, thanks for letting us know.

    What do you have so far, so we can try to see what you are having trouble with?
    Laugh, and the world laughs with you. Cry, and you just water down your vodka.


    Take credit, not responsibility

  3. #3
    Good Ol' Platypus Sastraxi's Avatar
    Join Date
    Jan 2000
    Location
    Ontario, Canada
    Posts
    5,134
    VB Code:
    1. Dim CD As Date 'Countdown
    2. Dim N As Date 'Now date
    3. Dim E As Date 'End date
    4.  
    5. N = Now
    6. E = Format("03-30-03", "MM-DD-YY")
    7.  
    8. CD = DateDiff(N, E)
    I've never used the DateDiff function before, but I think that's how it works... someone help this poor soul if I geot it wrong...
    All contents of the above post that aren't somebody elses are mine, not the property of some media corporation.
    (Just a heads-up)

  4. #4

    Thread Starter
    New Member
    Join Date
    Feb 2002
    Location
    Lake Zurich, Illinois
    Posts
    4
    I dont know how it is done, I have no idea where to start

  5. #5
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    very good example
    Attached Files Attached Files

  6. #6
    Software Eng. Megatron's Avatar
    Join Date
    Mar 1999
    Location
    Canada
    Posts
    11,286
    See this link

  7. #7

    Thread Starter
    New Member
    Join Date
    Feb 2002
    Location
    Lake Zurich, Illinois
    Posts
    4
    I am just looking to make one that is just a timer object and a label. No extra stuff involved, just a simple little form that will display just how many Days, Hours, Minutes, Seconds until March 30, 2003.

  8. #8
    PowerPoster
    Join Date
    Jun 2001
    Location
    Trafalgar, IN
    Posts
    4,141
    this is the way I would do it
    VB Code:
    1. Option Explicit
    2. Dim seconds As Double
    3. Dim minutes As Integer
    4. Dim hours As Integer
    5. Dim days As Long
    6. Dim target As Date
    7.  
    8.  
    9. Private Sub Form_Load()
    10.     target = #3/30/2003#     ' or CDate("March 30, 2003")
    11.     Timer1.Interval = 500
    12.     Timer1.Enabled = True
    13. End Sub
    14.  
    15. Private Sub Timer1_Timer()
    16. Dim strCap As String
    17.  
    18.     seconds = DateDiff("s", Now, target)
    19.    
    20.     If seconds < 0 Then
    21.         Timer1.Enabled = False
    22.         Exit Sub
    23.     End If
    24.  
    25.     days = seconds \ 86400
    26.     seconds = seconds - (days * 86400)
    27.    
    28.     hours = seconds \ 3600
    29.     seconds = seconds - (hours * 3600)
    30.    
    31.     minutes = seconds \ 60
    32.     seconds = seconds - (minutes * 60)
    33.    
    34.     strCap = days & "  Days" & vbCrLf
    35.     strCap = strCap & hours & "  Hours" & vbCrLf
    36.     strCap = strCap & minutes & "  Minutes" & vbCrLf
    37.     strCap = strCap & seconds & "  Seconds"
    38.    
    39.     Label1.Caption = strCap
    40. End Sub

  9. #9

    Thread Starter
    New Member
    Join Date
    Feb 2002
    Location
    Lake Zurich, Illinois
    Posts
    4
    Alright thanks guys

Posting Permissions

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



Click Here to Expand Forum to Full Width