Solved

sleep or wait function in VB

Posted on 2001-06-12
3
1,449 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
ID: 6183584
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
ID: 6183600
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
ID: 6183641

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

920 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