Sleep

How do you pause your program for a few seconds?

Well, you could try searching for these synonyms

but you probably won't find anything useful. It would be great if all languages provided help where any of these synonyms pointed to the appropriate command. If that was done, then this page would not be necessary.

In the old days, this was important because a one millisecond sleep command was used to allow the operating system to update the screen. Under MS Windows, similar functionality is needed for various reasons.

Visual Basic | Delphi | Windows API


Visual Basic 6.0

All the early DOS Basics had a sleep command. However, the new, improved VisualBasic has removed this most basic of commands. :(

Instead, you could use a Timer object - but this does not support good, logical program flow.

I prefer to use a direct Windows API call.

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

To just allow events to occur, try

But read my Visual Basic 6.0 Notes for a warning.


Delphi

These methods allow MS Windows to update the screen.


Windows API

This is the universal Windows method to provide this functionality.
Declare Sub Sleep Lib "kernel32" Alias "Sleep" (ByVal dwMilliseconds As Long)


Author: Robert Clemenzi - clemenzi@cpcug.org
URL: http:// cpcug.org / user / clemenzi / technical / Languages / Sleep.htm