|
-
Oct 15th, 2000, 08:55 PM
#1
Thread Starter
New Member
Hi All.
I'm looking for the best way to slow down a loop.
Is using a timer the best way to go.
Seems like a lot of overhead. I have done non productive
equations to slow things down also not good as it will
very a lot depending on the speed of the processor the
app is run on.
Any help greatfully accepted.
-
Oct 15th, 2000, 09:06 PM
#2
Lively Member
this works best for me - Spd is like 7000
Code:
Private Sub pause()
Dim i As Long
For i = 1 To Spd
DoEvents
Next
End Sub
there is an example at:
http://pages.about.com/vbmakai/sv1.htm
-
Oct 15th, 2000, 09:30 PM
#3
Thread Starter
New Member
Thanks Makai
Thanks Makai for the fast reply.
Used it seems to work fine.
Damien :-)
-
Oct 15th, 2000, 10:08 PM
#4
transcendental analytic
Code:
Declare Function GetTickCount Lib "kernel32" Alias "GetTickCount" () As Long
Private Sub pause(milliseconds as long)
Dim i As Long
i=Gettickcount+milliseconds
Do while Gettickcount<i
DoEvents
loop
End Sub
This ones a bit more adcanced, you can put the exact amount of millisecond for it to pause
Use  
writing software in C++ is like driving rivets into steel beam with a toothpick.
writing haskell makes your life easier:
reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.
-
Oct 16th, 2000, 10:31 PM
#5
Thread Starter
New Member
Thanks Kedaman
I looked up GetTickCount and found that it rolls over to
zero if the system has been running for 49.7 days(obviously
not running a MicroSoft OS). Still stranger things have
happened. The pause routine could go into an infinite loop
if it was running when a system rolled over.
May be worth testing if count has just rolled over.
Once again thankyou for the advice
Damien
Code:
Private Declare Function GetTickCount Lib "kernel32" () As Long
Private Sub pause(milliseconds As Long)
Dim i As Long
i = GetTickCount + milliseconds
Do While GetTickCount < i
If GetTickCount < 3000 Then Exit Do 'TickCount loops over to zero every 49.7 days
DoEvents
Loop
End Sub
[Edited by Damien on 10-16-2000 at 11:58 PM]
-
Oct 17th, 2000, 06:06 AM
#6
transcendental analytic
how about 29247 years!
Yeah, not only if you have running your system for that long, but also you can pause like some years if you want, hehehe
Code:
Private Declare Function GetTickCount Lib "kernel32" () As Long
Sub pause(milliseconds As Currency)
Dim i As Currency, j As Currency, k As Currency
j = GetTickCount
i = j + milliseconds
Do While (j + k) < i
If GetTickCount < j Then k = k + j
j = GetTickCount
DoEvents
Loop
End Sub
Use  
writing software in C++ is like driving rivets into steel beam with a toothpick.
writing haskell makes your life easier:
reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.
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
|