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

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

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

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
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…
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…
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…

809 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