Link to home
Start Free TrialLog in
Avatar of sml41
sml41

asked on

timer

I am reading from an access database, i need a timer to triger this reading every 15 minutes, 30,45, and 60 minutes. I have not used timers before so please suggest anything

thanks
ASKER CERTIFIED SOLUTION
Avatar of mcrider
mcrider

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of mcrider
mcrider

The example I gave you wil kick off the timer once a second, looking to see if the system clock is at one of the quarter hours...  You can increase to timer intercal property to 60000 and it will check once a minute...



Cheers!
With an interval of 1000 would you not execute up to60 times for each of the cases?

With a setting of 60000 you might miss depending on timing.

You are limited to 65000 as the max setting so this causes a problem. Most set up a public counter and with a setting of 60000 you count the counter until it gets to 15.

I would be interested in a slick way to do this.
danlevans,

sml41 is looking to fire an event at the quarter hours. Even at setting the timer to 60000 you will not miss the event, because the code looks at the system clock's minute value...

Cheers!
mcrider

I see what he wants. What you give him is something different. With timer at 1000 it will fire 60 times in one minute. It will find the clock at 15 minutes 60 times!

Now at 60000 if the event fires 60000 one millisecond before 15 goes to 16 you will probably miss it.

Cheers!!
I was assuming that sml41 would know how to stop an event from firing multiple times... Ok...

using the original code, add a second timer and disable it. then in timer1 Event, do the following:
 
   Select Case Val(Format(Now, "n"))
        Case 0, 15, 30, 45
            Timer1.Enabled = False
            '
            'YOUR EVENT GOES HERE
            '
            With Timer2
                 .Interval = 65535
                 .Enabled = True
            End With
    End Select

And in Timer2's Event:

   Timer2.Enabled = False
   Timer1.Enabled = True


Cheers!
well i want that the i want the beep after every 30 minutes from the time form is loaded

thanks
sonal
Avatar of sml41

ASKER

thank all