Excel 2003 VBA multithreaded?

M

mfc

Hi,

Suppose I have a OnTime macro that runs every 5 seconds and another macro
attached to a button.

Can I assume that each macro completes 100% before the other macro can
start?

I mean, while the OnTime macro is running, can it be interrupted by someone
clicking the button or vice versa?


thanks
 
P

Peter Huang [MSFT]

Hi

I understand you mean to add a Button on the UserForm and set a timer with
"Application.OnTime" method start.

This depends on how did you coding the VBA macro.
e.g.
If the Timer running as below, there is a DoEvents method inside a busy
loop, then when we click the Button, the Button event will fire
Sub Test()
While True
DoEvents
Debug.Print "Running"
Wend
End Sub

For the code below, the button click event will not fire, and when the loop
is busy, we even can not click the button on the user form.

Sub Test()
While True
Debug.Print "Running"
Wend
End Sub

If you have any concern, please feel free to post here.


Best regards,

Peter Huang

Microsoft Online Community Support
==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top