|
-
Mar 26th, 2003, 06:55 PM
#1
Thread Starter
Junior Member
Which use?
Hi,
I search around VbForums trying to find the best way to make some Events running every X minutes (define by user, each minute up to 2 hours).
I know the Timer object. I found GetTicketCount and SetTimer API. But I don't know which one is the best for my needs. I don't want something that eat up CPU.
I want to know your opinion about it.
Thanks a lot guys.
-
Mar 26th, 2003, 07:00 PM
#2
Addicted Member
What is it you want to do exactly. You could manage to just run a basic timer and set the interval like so:
VB Code:
Private Sub Command1_Click()
timer1.interval = text1.text
timer1.enabled = True
End Sub
Private Sub Timer1_Timer()
'Your commands go here
End Sub
This will get the timers interval from a text box then enable the timer. Once enabled it will run the commands attached to itself...
Note: Timers run in milliseconds (1 second = 1000 millisecond)
I really dont understand what you're trying to do...sorry
Quis Custodiet Ipsos Custodes?
You don't have to be faster than the bear, you just have to be faster than the slowest person running from the bear.
-
Mar 26th, 2003, 07:11 PM
#3
Thread Starter
Junior Member
It's because I read that the Timer object was limited to 65 XXX (equal to ~1 minute) so if the user ask to make a check every 2 hours I didn't see how I can do it with this ojbect.
I made a program who check every X minutes (or hour) the IP of a router (IP provide by the ISP). So I want to let the user choose himself the interval of the check.
-
Mar 26th, 2003, 07:26 PM
#4
Addicted Member
This gets tricky...
I see your dilemma. Im not good with API so I have 2 non-API solutions for you...but be aware API is probably better than these two:
Solution 1: The variable way!
VB Code:
Dim time as integer
Dim min as integer
Private Sub Command1_Click()
'get the time in min not seconds
min = text1.text
time = 0
End Sub
'Timer interval should be 60000 (one min)
Private Sub Timer1_Timer()
'Add 1 to time every 1 min
time = time + 1
End Sub
'Check if the time is up
Private Sub Timer2_Timer()
If time = min then
'Put your commands here
End If
End Sub
Solution 2: The math way!
I can only explain this one. If you get the system time and put it in Var1 then get the system time + interval and put it in Var2 then make an If statement:
VB Code:
If var1 = var2 then
'Your commands here
End If
I didn't do this in VB so there may be syntax errors!
Quis Custodiet Ipsos Custodes?
You don't have to be faster than the bear, you just have to be faster than the slowest person running from the bear.
-
Mar 26th, 2003, 08:35 PM
#5
Thread Starter
Junior Member
Thanks Illiad, I will try this.
Someone got something with API? I want to learn more about those method.
Thanks
-
Mar 26th, 2003, 09:05 PM
#6
Addicted Member
Try posting in the API forum. It may give more results...
Quis Custodiet Ipsos Custodes?
You don't have to be faster than the bear, you just have to be faster than the slowest person running from the bear.
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
|