Hi,
I'd like to call a Function in my App every 5 minutes. Does vb allow me to do so? How?
thanks,
-vb
Printable View
Hi,
I'd like to call a Function in my App every 5 minutes. Does vb allow me to do so? How?
thanks,
-vb
You can do that with a timer control. A 60000 interval is one minute, so 5 minutes would be 300000. It's not completly accurate to the millisecond, but it's close.
How? Some code please.
set the interval to 300000
like..
timer1.interval = 300000
and put ur code in
timer1_timer()
'ur code.....
end sub
A timer in Visual Basic can have a maximum interval of a value of an integer (65,536). You cannot set its interval to 300000
You'll need to use the API timer calls.
Or,
Set your timer to 60000 (1 minute).
Declare a public variable and increment it by 1 each time the timer event fires.
If the variable's value is 5, you know that 5 minutes have passed, then do your stuff and set the variable back to 0
Use an IE timer, they have an interval of one second, so you can go to much longer times.
Private Sub Timer1_Timer()
Static numCalls As Long
Timer1.Interval = 1000000
numCalls = numCalls + 1
If numCalls = 2 Then
Call MySub
numCalls = 0
End If
End Sub
ok