Solved

Making you app wait without Sleep()?

Posted on 1997-04-23
1
151 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
Comment Utility
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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

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 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…

763 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

10 Experts available now in Live!

Get 1:1 Help Now