Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 322
  • Last Modified:

Count Down Accurate Timer

I need a accurate timer that can count down from 1 hour to nothing then display a msgbox but I have a picture of each number because i couldn't find an appropriate font
0
cheezy102
Asked:
cheezy102
1 Solution
 
sazhagianambiCommented:
Hi,

Delare One Variable i
Place One Timer.

Set Interval as 60,000(60 Sec ie 1 min)

Private Sub Timer1_Timer()
   i = i + 1
   if i=60 then 'One Hour Reached
     'Place Your Code here
   end if
End Sub

Regards,
Nambi
0
 
CimperialiCommented:
In a Bas module
'------------------------------------------------
Option Explicit
Public Declare Function SetTimer Lib "user32" (ByVal hwnd As Long, ByVal nIDEvent As Long, ByVal uElapse As Long, ByVal lpTimerFunc As Long) As Long
Public Declare Function KillTimer Lib "user32" (ByVal hwnd As Long, ByVal nIDEvent As Long) As Long
Public intCounter As Integer
Sub TimerProc(ByVal hwnd As Long, ByVal nIDEvent As Long, ByVal uElapse As Long, ByVal lpTimerFunc As Long)
    intCounter = intCounter + 1
    If intCounter > 60 Then
      intCounter = 0
    End If
    'show your pic:
    'if you have an array of pics, you can write:
    'FormMsg.Image = YourPicture(60-intCounter)
    'or, if pictures images are saved in reverse order:
    'FormMsg.Image = YourPicture(intCounter)
    Show FormMsg, vbModal
End Sub
'----------------------------------
In a form:
'----------------------------------
Option Explicit
Private Sub Form_Load()
   'for delay slower than 1 min, remember this
   'parameter is millisecond...
   Dim theDaly As Long
   theDelay = 60000 '=1 minute => 60 sec * 1000
   SetTimer Me.hwnd, 0, theDelay, AddressOf TimerProc
End Sub

Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
   KillTimer Me.hwnd, 0
End Sub
'-------------------------------------
'You need another form to display msg. In code I have called it
"FormMsg"
'and displayed it as modal form...
'-------------------------------------
0
 
JacamarCommented:
ok, both of those are ok, however I would just like to add that setting the inteval to 1000 is very close to one second, but it is not exactly the same.  When you get in to the area of one hour, your time may be inaccurate to a degree that you are not satisfied with.  However, it may be fine for your purposes.  
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
CimperialiCommented:
To Jacamar:
---------------------------------------
Using settimer, you can choose the delay. You could choose
even 1 hour, if you like
(simply multiply milliseconds = 1 h = 1000* 60*60= 3600000)
as it is a long value, it can hold 3.600.000...
cheers
Cesare I.
0
 
JacamarCommented:
ok, i know  you can do that........however, those timers are not exact time.  Try it.  Compare it to your computer's time.  The timer in VB runs about 10 seconds per hour slower than the timer on your machine.
0
 
MILUCommented:
Hello all experts ,
   Can u please pay attection to the query related to TIMER control

http://www.experts-exchange.com/Programming/Q_20559986.html

0
 
cheezy102Author Commented:
Thanx a lot for that mate, It's quite complicated but I think i'll get it sooner or later. Nice one
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now