Count Down Accurate Timer

Posted on 2003-03-26
Medium Priority
Last Modified: 2010-05-01
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
Question by:cheezy102
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions

Expert Comment

ID: 8209926

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


Accepted Solution

Cimperiali earned 500 total points
ID: 8210043
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
'and displayed it as modal form...

Expert Comment

ID: 8210774
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.  
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!


Expert Comment

ID: 8211608
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...
Cesare I.

Expert Comment

ID: 8212683
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.

Expert Comment

ID: 8216037
Hello all experts ,
   Can u please pay attection to the query related to TIMER control



Author Comment

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

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses
Course of the Month8 days, 12 hours left to enroll

765 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question