Making you app wait without Sleep()?

Posted on 1997-04-23
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.
Question by:vbpro
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment

Accepted Solution

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)
any thing that you want

Wait more time ...

Dim i as integer

Set Db = dbengine.opendatabase(datapath)

for i = 1 to 20
next i
any thing that you want

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

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

734 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