#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default DoEvent

I am a neophyte programmer, I heard DoEvents can be used to run tw
sequence at almost the same time. But I dont know how to use it.
Anyone kind enough to show me how it works? A sample coding will do an
a bit expanation how it works.

Thanks

--
Message posted from http://www.ExcelForum.com

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 599
Default DoEvent

Billabong

DoEvents releases the processor from the currently executing macro for
whatever is in the processors queue. You normally should not need it, but
there are times when you do. Here's an example: Suppose you have a macro
that increments the value of a cell until the user hits a button. You might
set that up like this

Public bStop As Boolean

Sub IncrementCell()

Do
Range("A1").Value = Range("A1").Value + 1
DoEvents
Loop Until bStop

End Sub

Sub StopIncrement()
'assigned to button

bStop = True

End Sub

If you didn't have the DoEvents in the first sub, the button would never be
available for the user to hit because the IncrementCell would never release
any processor time to anything else. Clicking the button to StopIncrement
will not do anything because StopIncrement will be in the processor's queue
waiting for IncrementCell to finish, which of course it never would.

--
Dick Kusleika
MVP - Excel
Excel Blog - Daily Dose of Excel
www.dicks-blog.com

"Billabong " wrote in message
...
I am a neophyte programmer, I heard DoEvents can be used to run two
sequence at almost the same time. But I dont know how to use it.
Anyone kind enough to show me how it works? A sample coding will do and
a bit expanation how it works.

Thanks.


---
Message posted from http://www.ExcelForum.com/



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default DoEvent

Excel isn't multitasking and won't run two procedures at the same time.


as far as DoEvents, it is explained pretty well in Help:

"Yields execution so that the operating system can process other events."
If that is what you mean by two sequence then it can do that, but the second
sequence, the operating system tasks, are outside your control.

for i = 1 to 1000
doevents
' other actions
Next

might be useful if the code were making visible changes and they were not
being updated on the screen because the code is in a tight loop. Doevents
is usually used primarily when problems are encountered.

--
Regards,
Tom Ogilvy



"Billabong " wrote in message
...
I am a neophyte programmer, I heard DoEvents can be used to run two
sequence at almost the same time. But I dont know how to use it.
Anyone kind enough to show me how it works? A sample coding will do and
a bit expanation how it works.

Thanks.


---
Message posted from http://www.ExcelForum.com/



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 10:08 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"