|
-
Jun 6th, 2000, 08:46 PM
#1
Thread Starter
Lively Member
Does anyone know how I can get my program to perform an action every 30 minutes. This amount is too big for a timer. I have tried putting it into a loop checking to see if the oldtime + 30 mins equals new time, but it stops responding properly
Thanks a lot
Mark
-
Jun 6th, 2000, 08:54 PM
#2
Fanatic Member
You can use a timer. You will also need a variable.
Code:
Timer1.Interval = ?? 'whatever you chose.
Private Sub Timer1_Timer()
Static iTime As long
iTime = iTime + Timer1.Interval
If iTime >= 1800000 Then '30 minutes
'do something.
iTime = 0
End If
End Sub
Iain, thats with an i by the way!
-
Jun 6th, 2000, 09:04 PM
#3
Thread Starter
Lively Member
Thanks. Why didn't I think of that myself?
-
Jun 7th, 2000, 08:58 AM
#4
PowerPoster
SetTimer API
I think this is better, because it does not need any OCX control.
Code:
Option Explicit
Private Declare Function SetTimer Lib "user32" (ByVal hwnd As Long, ByVal nIDEvent As Long, ByVal uElapse As Long, ByVal lpTimerFunc As Long) As Long
Private Declare Function KillTimer Lib "user32" (ByVal hwnd As Long, ByVal nIDEvent As Long) As Long
Sub TimerProc(ByVal hwnd As Long, ByVal nIDEvent As Long, ByVal uElapse As Long, ByVal lpTimerFunc As Long)
MsgBox "30 minutes is over."
End Sub
Private Sub Form_Load()
SetTimer Form1.hwnd, 0, 1800000, AddressOf TimerProc
End Sub
Private Sub Form_Unload()
KillTimer Form1.hwnd, 0
End Sub
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
|