setting a delay in VBA

setting a delay in VBA

Anonymous
Not applicable
2,839 Views
5 Replies
Message 1 of 6

setting a delay in VBA

Anonymous
Not applicable
I have a VBA command button that first hides the form and then does its
thing. Unfortunately, the form seems to stay visible during the execution
and then hides at the end.

is there any kind of delay command (like autocad scripts DELAY 5000
command)?
0 Likes
2,840 Views
5 Replies
Replies (5)
Message 2 of 6

Anonymous
Not applicable
You should be able to do something with the Timer control, setting it to
1/10 of a second should be enough -- pressing the button would hide the form
and enable a disabled timer, and in the timer's Timer event, set an
incrementer -- and when that increment reaches a certain value, disable the
timer and run what ever code you need.

"cad user-Sean" wrote in message
news:DC7F40B20AE950715CA2F5E28C93203F@in.WebX.maYIadrTaRb...
> I have a VBA command button that first hides the form and then does its
> thing. Unfortunately, the form seems to stay visible during the execution
> and then hides at the end.
>
> is there any kind of delay command (like autocad scripts DELAY 5000
> command)?
>
0 Likes
Message 3 of 6

Anonymous
Not applicable
Instead of a delay, try just putting DoEvents in your code in various
places - this will allow the os to refresh the screen.

"Lanny Schiele" wrote in message
news:039C08B5750E6446B481B998EB874B68@in.WebX.maYIadrTaRb...
You should be able to do something with the Timer control, setting it to
1/10 of a second should be enough -- pressing the button would hide the form
and enable a disabled timer, and in the timer's Timer event, set an
incrementer -- and when that increment reaches a certain value, disable the
timer and run what ever code you need.

"cad user-Sean" wrote in message
news:DC7F40B20AE950715CA2F5E28C93203F@in.WebX.maYIadrTaRb...
> I have a VBA command button that first hides the form and then does its
> thing. Unfortunately, the form seems to stay visible during the execution
> and then hides at the end.
>
> is there any kind of delay command (like autocad scripts DELAY 5000
> command)?
>
0 Likes
Message 4 of 6

Anonymous
Not applicable
could you elaborate?sean
"Kevin Terry" wrote in message
news:10DD87C3199654F0D5881A6DA7F95390@in.WebX.maYIadrTaRb...
> Instead of a delay, try just putting DoEvents in your code in various
> places - this will allow the os to refresh the screen.
>
> "Lanny Schiele" wrote in message
> news:039C08B5750E6446B481B998EB874B68@in.WebX.maYIadrTaRb...
> You should be able to do something with the Timer control, setting it to
> 1/10 of a second should be enough -- pressing the button would hide the
form
> and enable a disabled timer, and in the timer's Timer event, set an
> incrementer -- and when that increment reaches a certain value, disable
the
> timer and run what ever code you need.
>
> "cad user-Sean" wrote in message
> news:DC7F40B20AE950715CA2F5E28C93203F@in.WebX.maYIadrTaRb...
> > I have a VBA command button that first hides the form and then does its
> > thing. Unfortunately, the form seems to stay visible during the
execution
> > and then hides at the end.
> >
> > is there any kind of delay command (like autocad scripts DELAY 5000
> > command)?
> >
>
0 Likes
Message 5 of 6

Anonymous
Not applicable
Lanny! I've been looking all over for ya! Hey, I crashed recently and lost
all my email. Would you mind resending the code I was going to publish?

--
http://www.acadx.com
Win an autographed copy of
"Mastering AutoCAD 2000 Objects"
by Dietmar Rudolph
0 Likes
Message 6 of 6

Anonymous
Not applicable
Sometimes I like to display a message on a form to let a user know what is
happening in the background but the action happens so fast that the label
isn't even displayed.I use this little routine to delay things for a second
or two just so things get held up a tad. It works great for "shell" too
since you can't be sure the shell app is finished before your code resumes.

Hope it helps.

Dale Levesque

Call it like this:

g_sb_Delay 2 ' (delays approx 2 seconds)

Here's the code:

Public Sub g_sb_Delay(ai_Count As Long)

Dim Start As Long
Dim I As Long
I = 0

Start = Timer ' Set start time.
Do While Timer < Start + ai_Count
DoEvents ' Yield to other processes.
Loop

End Sub
0 Likes