Time Counter

  • Thread starter Thread starter Prav
  • Start date Start date
P

Prav

Hi, I have a VBA code running a set of queries. How can I add a time
ticker/counter - Day, Hours, Minutes and Seconds starting like Day: 0 Hours:0
Minutes: 0 Seconds: 0. Cheers
 
Prav said:
Hi, I have a VBA code running a set of queries. How can I add a time
ticker/counter - Day, Hours, Minutes and Seconds starting like Day: 0
Hours:0
Minutes: 0 Seconds: 0. Cheers

Here's some code I wrote to countdown to the millenium. Put a label on your
form, put this code in the form's Timer event, and set the TimerInterval to
1000:

Private Sub Form_Timer()
Dim dtNow As Date
Dim strOut As String
Dim lngTmp As Long
Dim lngTmp2 As Long
Dim lngTmp3 As Long
Dim lngTmp4 As Long
Const con2000 As Date = #1/1/2000#

dtNow = Now
lngTmp = DateDiff("s", dtNow, con2000)
lngTmp2 = CLng(lngTmp / 86400)
lngTmp3 = lngTmp2 Mod 24
lngTmp4 = (lngTmp3) Mod 60
'strOut = lngTmp2 & " days " & lngTmp3 & " hours "
'strOut = strOut & " left until the Millenium!!"
Me.lbl2000.Caption = CStr(Int(con2000 - dtNow)) & IIf(con2000 - dtNow > 1,
" days ", " day ") & Format$(con2000 - dtNow, "hh:nn:ss") 'strOut
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top