Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17


time delay

Posted on 1999-07-22
Medium Priority
Last Modified: 2010-04-30
I´ve found a really nice tip for stop the code for x seconds.
It goes like this:

Sub Pause(ByVal nSecond As Single)
Dim t0 As Single
Dim dummy As Integer
        t0 = Timer
        Do While Timer - t0 < nSecond
                dummy = DoEvents()
                ' If we cross midnight, back up one day
                If Timer < t0 Then
                        t0 = t0 - 24 * 60 * 60 ' or t0 = t0 - 86400

                End If

End Sub


Private Sub Command1_Click()
Dim x As Integer
x = seconds.Text

Call Pause(x)  ' delay for x seconds
Label1.Caption = "ok"
End Sub


The problem I had is: How can I use this if I want to stop the code for less than a second?

But it really is a nice tip!!!

Thx for your help guys!

Question by:alexbeaty
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
  • 3

Accepted Solution

stewfidgeon earned 40 total points
ID: 1526693
I dont think you can. You can however use the sleep API to pause execution for milliseconds.

An example of this can be found at :
called sleepy eyes.

Hope this helps.

Expert Comment

ID: 1526694

Is my answer OK? Can you either accept it or reject it please.

If you want a simpler example of sleep API, follow this link:


Expert Comment

ID: 1526695

I took the time to answer your question, I think it's fair that you should spend the time to grade my answer.


Featured Post

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Question has a verified solution.

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

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
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…
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…
Suggested Courses

721 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