Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Making you app wait without Sleep()?

Posted on 1997-04-23
1
Medium Priority
?
160 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 100 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

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

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

Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…
Suggested Courses

971 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