Need to halt execution of code for brief timeframe

I am new to VB and my code is executing so fast that it is processing some files before the previous file finished processing.  Is there a command that will halt execution for a very short timeframe say .5 to 1 second before it continues?  I have been looking at Sleep but don't know if that is best or if there are other commands that are more useful.

Thanks in advance,
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

You can use:

Public Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)

Then call it using:

Sleep (500)

Or you can do something like this:

Dim sngTimer As Single
sngTimer = Timer + 0.5
Do While Timer < sngTimer

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Either will do the job.  But, if you time it out just right so that the 1/2 of a second lands at exactly 12:00:00 AM midnight, it might cause a problem so you can do something like this:

Dim sngTimer As Single
Dim sngStartTimer As Single
sngTimer = Timer + 0.5 '**** Add 1/2 second (500 ms) to the current time
sngStartTimer = Timer '**** Store the current value of Timer
Do While Timer < sngTimer '**** Loop while the value of Timer is less than the start time plus 500 ms
     If Timer < sngStartTimer Then '**** If we hit midnight and timer is now less than it's starting value, exit the loop
           Exit Do '**** Exit the loop
     End If
     DoEvents '**** DoEvents so we don't look like the program isn't responding
BubbaisBestAuthor Commented:
Thank you for all your help codeconqueror.

I just used the Sleep methodology and it comes out fine now at .5 seconds.

No prob. :)
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.