|
-
Dec 20th, 2005, 12:50 AM
#1
Thread Starter
Fanatic Member
how to set timer.interval = 1 hour?
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
noister
<advertising link removed by moderator>
-
Dec 20th, 2005, 12:53 AM
#2
Re: how to set timer.interval = 1 hour?
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
-
Dec 20th, 2005, 12:56 AM
#3
Re: how to set timer.interval = 1 hour?
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
-
Dec 20th, 2005, 12:58 AM
#4
Re: how to set timer.interval = 1 hour?
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.
Pete
No trees were harmed in the making of this post, however a large number of electrons were greatly inconvenienced.
-
Dec 20th, 2005, 01:11 AM
#5
Thread Starter
Fanatic Member
Re: how to set timer.interval = 1 hour?
ah, ok! tnx to all, dee-u i'm from cebu, phil to...
-
Dec 20th, 2005, 02:03 AM
#6
Frenzied Member
Re: how to set timer.interval = 1 hour?
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
-
Dec 20th, 2005, 02:09 AM
#7
Re: how to set timer.interval = 1 hour?
Wasn't that posted at least three times in this thread alone?
-
Dec 20th, 2005, 03:13 AM
#8
Frenzied Member
Re: how to set timer.interval = 1 hour?
No one else used the DateDiff() Function, hoser.
Also, none of the above solutions are very accurate in time keeping, the Date functions are.
Last edited by Spajeoly; Dec 20th, 2005 at 03:20 AM.
-
Dec 20th, 2005, 03:21 AM
#9
Thread Starter
Fanatic Member
Re: how to set timer.interval = 1 hour?
tnx Spajeoly! actually i already solved my problem, but tnx for your other idea... i learn a lot here!...
-
Dec 20th, 2005, 03:33 AM
#10
Frenzied Member
Re: how to set timer.interval = 1 hour?
Sure thing...
-
Dec 20th, 2005, 04:49 AM
#11
Re: how to set timer.interval = 1 hour?
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.
-
Dec 20th, 2005, 04:53 AM
#12
Re: how to set timer.interval = 1 hour?
Post #3, you could set your watch by it. It uses dateadd() for the timer.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|