Solved

sleep or wait function in VB

Posted on 2001-06-12
3
1,447 Views
Last Modified: 2011-04-14
Is there a way to code a sleep or wait function in VB?
0
Comment
Question by:arichee
3 Comments
 
LVL 4

Accepted Solution

by:
beckingh earned 100 total points
Comment Utility
yep...

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
0
 
LVL 2

Expert Comment

by:bhh
Comment Utility
Sub Wait10Sec()
    Dim dtGoal As Date
    dtGoal = DateAdd("s", 10, Now)
    Do While dtGoal > Now
    Loop
End Sub
0
 
LVL 4

Expert Comment

by:mcoop
Comment Utility

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)

0

Featured Post

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now