Not a Member Yet,
Click here to Register
How do you like the new design?
It's cool, great job
[tally: 70%] 70%
It's okay
[tally: 20%] 20%
Its OK but I liked the old layout better
[tally: 0%] 0%
Please bring the old one back
[tally: 10%] 10%

votes: 10

ID: 287
Viewed: 2375
Added: Jul 26, 2002
Version:
Snippet uploaded by: snippet
Written By: unknown
Demo: Sorry, no demo



User Rated at: 0 Stars
Rate This:

Thank you for your vote. Please wait...

It appears you already voted for this snippet

It appears your vote value was empty

Now, for more accurate delays that don't meddle with the operation of your program, you can use GetTickCount. GetTickCount is a call that returns an insanely large number that is the exact number of milliseconds that Windows has been running since it was booted. The GetTickCount API declaration goes like this: see code

Second Part:
Now, to actually make a delay, you need to do a little fancy footwork. You'll need two varibles. One should be a global (so it will remain if the subroutine happens to end) called something like "GlobalDelay". The second is just a temporary variable and can be called "Temp" or something. Also, you'll have to set GlobalDelay to the current tick count at the beginning of your program like this:

You can tack other things inside the loop to repeat during the delay (screen refreshes, mayhap?) or yo can put things below it and constantly loop back to the top of the procedure, which gives you the delay, executes the code after it, gives the delay, executes the code, &c.

Highlight all by clicking in box
<!---Declaration--->
'code:---------------------------------------------------
Declare Function GetTickCount Lib "kernel32" () As Long
'------------------------------------------------
'Operation is dead simple, you just drop it into a 'variable:

'code:--------------------------------------
Variable = GetTickCount
'-------------------------------------------

Highlight All
<!---Code--->
'Second part
'code:------------------------------------------------
Sub Form_Load()
GlobalDelay = GetTickCount
End Sub
---------------------------------------------------
'Now, for a delay of a set amount, it would work like this:

'code:-----------------------------------------------
Temp = GetTickCount 'Get the current tick count into Temp.
Do While Temp < GlobalDelay + 1000 'Compare Temp to GlobalDelay. You can change the 1000 there to anything you want.
DoEvents 'Keeps it from meddling with program operation.
Loop
GLobalDelay = Temp 'Sets up GlobalDelay for next time.
'-------------------------------------------------------
;


No Comments to show

Please completely fill out the form below if you want to review this snippet. All reviews are subject to validation.


Replying to a Comment...


Adding your comment. Please wait...

Thanks for adding your comment!. After further review it will be added.

There was a problem adding your comment. Please try again.

Please complete all the fields in the form before sending.

© 2002 - 2017 snippetlibrary.com All Rights Reserved. Conditions