Not a Member Yet,
Click here to Register

ID: 287
Viewed: 2893
Added: Jul 26, 2002
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
Declare Function GetTickCount Lib "kernel32" () As Long
'Operation is dead simple, you just drop it into a 'variable:

Variable = GetTickCount

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

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.
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 - 2024 All Rights Reserved. Conditions
Do NOT follow this link or you will be banned from the site!