i want to have something happen every 30 minutes, like open iexplore. how do i do that
Printable View
i want to have something happen every 30 minutes, like open iexplore. how do i do that
Create a timer and set the interval to 60000. Now add this code to the general declarations section of your form:
And add this code to the Timer Event of the timeCode:Dim Minutes As Integer 'the number of minutes since the last 30 mins
Code:'add one to the counter
Minutes = Minutes + 1
'check if 30 is reached
If Minutes > 29 Then
'reset the counter
Minutes = 0
Msgbox "30 minutes are elapsed"
End If
You could also use the GetTickCount API...
A bit more accurate
[Edited by dsy5 on 11-04-2000 at 05:49 PM]Code:'Put in a module
Option Explicit
Private Declare Function GetTickCount& Lib "kernel32" ()
Public Sub Timed_Event(ByVal Interval As Long)
'Interval in minutes
Dim Start As Long
'Set Start of timer
Start = GetTickCount
'Check for to see if interval elapsed, else loop
Do While GetTickCount < Start + (Interval * 60000)
'allow other processes
DoEvents
Loop
'Your code goes here
End Sub
No API/Timer needed.
[Edited by Matthew Gates on 11-05-2000 at 03:36 AM]Code:Private Sub Command1_Click()
Time = "00:00:00"
Do
Time2 = Format(Time, "hh:nn:ss")
If Time2 = "00:30:00" Then MsgBox "Times up!": Exit Do
DoEvents
Loop
End Sub
I think you need to change 29 to 30.Quote:
Originally posted by Matthew Gates
Code:If Time2 = "00:29:00" Then MsgBox "Times up!":
Oops. The little things...
it was this line that I was looking at while writing the code:
If Minutes > 29 Then
So I was thinking 29. Don't know why.
Hope BuggyProgrammer get's the point anyway.
Nothing the little edit/delete image can't handle to fix the problem though :rolleyes:.
http://forums.vb-world.net/showthrea...threadid=20868
The dll raises events, so you don't have to use loops.
If you want it, give me a shout.
td.
Use the Timer function. It's similar to GetTickCount except it goes in intervals of 1000 ms rather than 1.
Usage:Code:Sub NewTimer(ByVal Interval As Long)
Do
Start = Timer
Do While Timer < Start + Interval
DoEvents
Loop
Loop
End Sub
Code:'Start Timer in intervals of 30 min
NewTimer 1800
or better, use SetTimer / KillTimer APIs
it calls the function u specify (one of the params is the adress of the func - use AddressOf) when the time interval has passed, and u dont have to have any loops - ppl can still use the app.
thanyou