|
-
Dec 30th, 2002, 09:28 AM
#1
Thread Starter
Junior Member
10 minute timer
Hello
I am in need of some big help to be able to set a timer interval (an event) to occur every 10 minutes. The current timer controls only allow 65000ms. So I have the usualy code for the timer interval set:
tmrtimer.Interval = gettimerdef
tmrtimer.Enabled = True
where gettimerdef is defined by a value from a textbox.
I would like to wrap this somehow so that it only occurs every 10 minutes. Any suggestions will be greatly appreciated.
Rob
Thanks for the help !
RobJ
-
Dec 30th, 2002, 09:31 AM
#2
set the timer to 60000 which is 1 minute and use a static variable in the timer event to incriment it until it = 10... something like
VB Code:
Private Sub Timer1_Timer
Static iCount as Integer
if iCount = 10 then
iCount = 0
'YOUR CODE HERE
else
iCount = iCount + 1
end if
End Sub
-
Dec 30th, 2002, 10:08 AM
#3
PowerPoster
Alternatively, you can use the Timer API :
VB Code:
'in a form
Option Explicit
Private Sub Form_Load()
'Create an API-timer
SetTimer Me.hwnd, 0, 600000, AddressOf TimerProc
End Sub
Private Sub Form_Unload(Cancel As Integer)
'Kill our API-timer
KillTimer Me.hwnd, 0
End Sub
'in a module
Option Explicit
Public Declare Function SetTimer Lib "user32" _
(ByVal hwnd As Long, ByVal nIDEvent As Long, _
ByVal uElapse As Long, ByVal lpTimerFunc As Long) As Long
Public Declare Function KillTimer Lib "user32" _
(ByVal hwnd As Long, ByVal nIDEvent As Long) As Long
Public Sub TimerProc(ByVal hwnd As Long, ByVal nIDEvent As Long, ByVal uElapse As Long, ByVal lpTimerFunc As Long)
MsgBox "hello world"
End Sub
Last edited by amitabh; Dec 30th, 2002 at 10:14 AM.
-
Dec 30th, 2002, 10:19 AM
#4
-
Dec 30th, 2002, 10:41 AM
#5
Fanatic Member
VB Code:
Private Sub Form_Load() 'Or whatever event will begin the timing
Text1.Text = Now()
End Sub
Private Sub Timer1_Timer()
Timer1.Interval = 1000
TenMinutes = DateDiff("n", Text1, Now())
If TenMinutes = 10 Then
'Do Something
'Then reset Text1 to the new Now()
Else
'Don't Do Something
End If
End Sub
"I have not failed. I've just found 10,000 ways that won't work."
'Thomas Edison'
"If we knew what it was we were doing it wouldn't be called research, would it?"
'Albert Einstein'
VB6
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
|