Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

function that stop the program???

Status
Not open for further replies.

qdtb

Technical User
Mar 14, 2002
12
PR
Hi, I am a new user of VBA 6.0

I am making a little program but I need a function or a instruction that make a stop or wait some seconds and then continue the program .

in C language the function is sleep()
I need that function because I want to choose some data in a combo box and then printed in a msgbox.

But the problem is that the msgbox appear to fast and dont let me choose the desired option in the combo box.

Thank you

sorry for my english, I speak spanish
 
Hi,

you can use a api function:

Private Declare Sub APISleep Lib "kernel32" Alias "Sleep" (ByVal dwMilliseconds As Long)

Bye

LauDse
 
I use the following code in a .bas module that I use in all my projects.
Code:
Sub HangOn(delay)
Dim T, t1 As Variant
t1 = Now()
    Do While DateDiff(&quot;s&quot;, t1, Now) < delay
        For T = 1 To 1000#
        Next T
        DoEvents
    Loop
End Sub

When you want a pause/sleep/delay just use

Code:
HangOn(3)

for 3 seconds etc.
 
Have a look at your task-manager.
Running your code takes 99% of cpu time ;)
Just try sleep and look at the cpu time!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top