|
-
Mar 5th, 2008, 12:58 PM
#1
Thread Starter
Hyperactive Member
[RESOLVED] Timer Interval?
Hey folks,
I am looking to make a timer so that every 5 minutes it will activate a line of code, like a timer would.. But I can't get the timer to go over a certain amount of time..
I've tried "Timer1.Interval = 300000" but that doesnt seem to work, does anyone know a way around this or a peice of code that will do the same thing?
-
Mar 5th, 2008, 01:01 PM
#2
Re: Timer Interval?
The standard VB timer is only good for 65 seconds.
-
Mar 5th, 2008, 01:06 PM
#3
Re: Timer Interval?
CVMichael post a timer submission in our CodeBank that I just went and retrieved the URL for. It might help you out.
http://www.vbforums.com/showthread.php?t=511995
-
Mar 5th, 2008, 02:07 PM
#4
Re: Timer Interval?
wxmancanada, if your gonna use my code, then make sure you compile QPTimerThread, then open QPTimerTestSingleThread to see how the timer thread is loaded and used. (Also make sure the reference to the QPTimer is selected)
You can remove all the code in the TimerEvent() call except the line where ContinueTimer = True
You can put any interval you want when you start the timer.
-
Mar 6th, 2008, 11:30 AM
#5
Lively Member
Re: Timer Interval?
Set the timer for 60000 (60 seconds) and use a counter:
vb Code:
Private Sub Timer1_Timer()
Dim iMinutes As Integer
iMinutes = iMinutes + 1
If iMinutes = 5 Then
' 5 minutes have passed, run code:
MsgBox "5 minutes have passed", vbInformation, "Notice:"
iMinutes = 0 ' Reset
End If
End Sub
-
Mar 6th, 2008, 04:03 PM
#6
Re: Timer Interval?
Many options; here is another one:
1. in declarations section: Private tmrEventTime As Date
2. When ready to enable timer: tmrEventTime = DateAdd("n",5,Now())
3. In timer event: If Now()>tmrEventTime then ' 5 minutes elapsed
-
Mar 6th, 2008, 10:33 PM
#7
Thread Starter
Hyperactive Member
Re: Timer Interval?
 Originally Posted by __Russell__
Set the timer for 60000 (60 seconds) and use a counter:
vb Code:
Private Sub Timer1_Timer()
Dim iMinutes As Integer
iMinutes = iMinutes + 1
If iMinutes = 5 Then
' 5 minutes have passed, run code:
MsgBox "5 minutes have passed", vbInformation, "Notice:"
iMinutes = 0 ' Reset
End If
End Sub
That's perfect! Thank you!
-
Mar 7th, 2008, 10:42 AM
#8
Lively Member
Re: [RESOLVED] Timer Interval?
Simple is best.
Last edited by __Russell__; Mar 7th, 2008 at 11:12 AM.
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
|