BubbaisBest
asked on
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,
Bubs
Thanks in advance,
Bubs
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thank you for all your help codeconqueror.
I just used the Sleep methodology and it comes out fine now at .5 seconds.
Bubs
I just used the Sleep methodology and it comes out fine now at .5 seconds.
Bubs
No prob. :)
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
Loop