Solved

sleep or wait function in VB

Posted on 2001-06-12
3
1,457 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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
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…

713 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