sleep or wait function in VB

Is there a way to code a sleep or wait function in VB?
Who is Participating?
beckinghConnect With a Mentor Commented:

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

'Puts the app to sleep for the given number of milliseconds
'  Sleeps for a given number of seconds.
Public Sub Pause(ByVal seconds As Single)
   Call Sleep(Int(seconds * 1000#))
End Sub
Sub Wait10Sec()
    Dim dtGoal As Date
    dtGoal = DateAdd("s", 10, Now)
    Do While dtGoal > Now
End Sub

And now for the difference...

The first 'sleep' API will halt processing in your app for the duration of the sleep() routine.

The latter do-while-loop structure will allow you to call other processes within the loop if required (e.g. flash a message on the screen etc)

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.