Pause execution for few seconds in VB6


Timers control is familiar control in Visual Basic 6.0 which enable programmer to execute code within a specified intervals. But what you do when y want to keep computer delaying execution for few minutes/seconds? Here is the solution.
With the Timer object your can do this trick. Create a Sub to perform the delay operations.

Sub Pause(interval)
Current = Timer
Do While Timer – Current < Val(interval)
 DoEvents
Loop
End Sub 
Now call the Pause() with delay time as seconds
call Pause (1)  ‘will delay execution of statements for few seconds

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.