Solved

Making you app wait without Sleep()?

Posted on 1997-04-23
1
153 Views
Last Modified: 2008-03-06
How can I make my program wait a set period of time before resuming execution without Sleep. The problem with Sleep is that the user interface freezes.Example:Set Db = dbengine.opendatabase(datapath)' Wait 4 seconds Set rs =....----------------------This is not a real use, as their is no reason to wait for the database to load, but it does show what I want.
0
Comment
Question by:vbpro
1 Comment
 
LVL 1

Accepted Solution

by:
milton042297 earned 50 total points
ID: 1425636
Use the DoEvents.
 
DoEvents yields execution so that the operating system can process other events.

The DoEvents function returns the number of open forms.
DoEvents passes control to the operating system.  Control is not returned until the operating system has finished processing the events in its queue and  all keys in the SendKeys queue have been sent.
If parts of your code take up a lot of processor time, use DoEvents periodically to relinquish control to the operating system so that events, such as keyboard input and mouse clicks, can be processed without significant delay.

And here a example:

'*************************************
Set Db = dbengine.opendatabase(datapath)
Doevents
-
-
any thing that you want
-
-
'************************

Wait more time ...

Dim i as integer

Set Db = dbengine.opendatabase(datapath)

for i = 1 to 20
    Doevents
next i
-
-
any thing that you want
-
-
'************************
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

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.
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…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

777 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