hey anybody can help me on how to set the timer.interval into 1 hour and higher? 1 sec = 1000, so 1 min = 60000, but 5 min = 300000 get an error. invalid property. why? any help here plz... tnx in advance
Printable View
hey anybody can help me on how to set the timer.interval into 1 hour and higher? 1 sec = 1000, so 1 min = 60000, but 5 min = 300000 get an error. invalid property. why? any help here plz... tnx in advance
You could try it like this... But be aware that the timer control is not precise...
VB Code:
'Interval=60000 Private Sub Timer1_Timer() Static mCount As Long mCount = mCount + 1 If mCount >= 60 Then MsgBox "One hour" End If End Sub
Set the timer to an interval of 1000, and keep a counter until it gets up to 3600, which is an hour. Take a look at this example that I wrote. I added time and compared that to the ending time.
http://vbforums.com/attachment.php?attachmentid=38745
The Interval property is an unsigned integer which means the largest value it will accept is 65535. You need to do as dee-u or dglienna suggest.
ah, ok! tnx to all, dee-u i'm from cebu, phil to...
A Timer's interval can only be set to 60,000 (60 seconds). The best thing to do is have a start date which you can set in a variable using String = Now, then in your timer have it constantly check String Vs Now to see if an hour has gone by. You can use the Datedif() function for this.
VB Code:
Private Sub Timer1_Timer() If DateDiff("h", Now, String) >= 1 Then 'I may have these backwards 'Code here, it has been an hour, ARE YOU NOT LISTENING?!?! End If End Sub
Wasn't that posted at least three times in this thread alone? :(
No one else used the DateDiff() Function, hoser.
Also, none of the above solutions are very accurate in time keeping, the Date functions are.
tnx Spajeoly! actually i already solved my problem, but tnx for your other idea... i learn a lot here!...
:ehh:
Sure thing...
You should use the SetTimer() function. More efficient and accurate. Counting intervals using VB's timer is not a good idea.
If you need to you can search the Codebank section for a demonstration of using that function.
Post #3, you could set your watch by it. It uses dateadd() for the timer.