Results 1 to 3 of 3

Thread: Counting down to the next hour <<resolved>>

  1. #1
    j2k
    Guest

    Counting down to the next hour <<resolved>>

    Hi,

    Please could someone tell me the code to count down to the next hour (in seconds)

    TIA.


    PROBLEM RESOLVED.

  2. #2
    Frenzied Member
    Join Date
    Aug 2001
    Posts
    1,075
    This should do it.

    Put a Label and a Timer on a form and then paste this code.

    VB Code:
    1. Option Explicit
    2. Dim dStartTime As Date
    3.  
    4. Private Sub Form_Load()
    5.     Dim iCurSecs As Integer
    6.     Dim iCurMin As Integer
    7.     iCurMin = Abs(60 - Format$(Now, "n"))
    8.     iCurSecs = Abs(60 - Format$(Now, "s"))
    9.     dStartTime = DateAdd("n", iCurMin, Now)
    10.     dStartTime = DateAdd("s", iCurSecs, dStartTime)
    11.     Timer1.Interval = 1000
    12.     Timer1.Enabled = True
    13. End Sub
    14.  
    15. Private Sub Timer1_Timer()
    16.     Label1.Caption = Format$(Now - dStartTime, "n:ss")
    17. End Sub

    Greg
    Free VB Add-In - The Reference Librarian
    Click Here for screen shot and download link.

  3. #3
    j2k
    Guest
    Many thanks

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