Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Timer Control

Status
Not open for further replies.

anastasia

Programmer
Dec 13, 2000
111
GB
Hi I was wondering if anyone knows how to set the Timer Control's Interval to run every hour on the hour in VB.

Any help appreciated.
 
The interval property of a timer control con take values up to 64.767
It means that you can't set values more than one minutes.
You can set the interval to 60.000 and using a static variable check if the interval happens 60 times. Stevie B. Gibson
 
I would check your system clock about once a minute and determine if the time has changed and use this to trigger the event. The VB timer is very variable when it comes to counting hours.

Ex:
'general declarations'
Public CurrentHour as Integer

Private Sub Timer1_Timer()

' The hour part is sliced out of the time string, format
' makes it 24 hour format, Hr is always between 0 and 23
' and hour 0 comes after 23

Hr = Val(left$(format$(time,"HH:MM:SS"),2)

if Hr > CurrentHour OR (Hr = 0 and CurrentHour = 23) then
CurrentHour = Hr

' your on-the-hour code goes here'

end if

End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top