# Sleep Sub

`Declare Sub Sleep Lib "kernel32.dll" (ByVal dwMilliseconds As Long)`

Sleep pauses program execution for a certain amount of time. This is more accurate than using a do-nothing loop, waiting for a certain amount of time to pass.

dwMilliseconds
  The number of milliseconds to halt program execution for.

Example:

    ' Demonstrate Sleep
    Debug.Print "The time is " & Time$
    Sleep 2000  ' 2000 milliseconds = 2 seconds
    Debug.Print "The time is " & Time$  ' 2 seconds later

Category: Miscellaneous
Back to the index.