473,387 Members | 1,365 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Exactly WHAT is accomplished with "DO EVENTS"?

Hello group,

Somehow, I have not yet fully understood the meaning and purpose of
"DoEvents". Can someone post or point me to a clear, concise
explanation of it -- one that includes situational examples of how and
why it is used? The Access on-line help is not as helpful as I need
for my mental density!

Sorry to be so dense. Please indulge me.

Thanks,

--LW
Nov 13 '05 #1
6 37169
On Wed, 29 Sep 2004 09:00:08 -0500, Lauren Wilson <???@???.???> wrote:
Hello group,

Somehow, I have not yet fully understood the meaning and purpose of
"DoEvents". Can someone post or point me to a clear, concise
explanation of it -- one that includes situational examples of how and
why it is used? The Access on-line help is not as helpful as I need
for my mental density!

Sorry to be so dense. Please indulge me.

Thanks,

--LW

Hi
Good question. I suspect it dates from Windows 3.1 before preemptive
scheduling. According to the help file for Access 97 (which had a
useful one) it "Yields execution so that the operating system can
process other events." If so it is now redundant.

(Though Access traditionally hogs processor cycles it does give way
when other processes nee them)

Over the years I have often stuck it in when things seem to be going
wrong in the timing sense but it's never made the slightest
difference,
David Schofield

Nov 13 '05 #2
From the Access Cookbook (Getz-Litwin-Baron):
"Sometimes Access seems to come to a halt... Effective use of DoEvents can make the difference ..."

Make a testform with a button cmdDoEvents and a label lblGrow (backgroundcolor as you like)
Code:
Private Sub cmdDoEvents_Click()
Dim intI As Integer
Me!lblGrow.Width = 500
For intI = 0 To 2500 Step 1
Me!lblGrow.Width = Me!lblGrow.Width + 1
'Me.Repaint
DoEvents
Next intI
End Sub

Try to push the button with and without the line DoEvents
(Without DoEvents use Me.Repaint to see the screen repaint).

The difference is when for instance you try to move the form.
-- When you don't use DoEvents you can't move the form WILE the code is running.
Your 'movement' (or other mouseclicks) will be executed AFTER the code is finished.
--When you use DoEvents you can smoothly move the form (code waits until you are done)

Sometimes this can make the difference indeed ...

HTH
Arno R

"Lauren Wilson" <???@???.???> schreef in bericht news:hn********************************@4ax.com...
Hello group,

Somehow, I have not yet fully understood the meaning and purpose of
"DoEvents". Can someone post or point me to a clear, concise
explanation of it -- one that includes situational examples of how and
why it is used? The Access on-line help is not as helpful as I need
for my mental density!

Sorry to be so dense. Please indulge me.

Thanks,

--LW

Nov 13 '05 #3
Lauren Wilson wrote:
Hello group,

Somehow, I have not yet fully understood the meaning and purpose of
"DoEvents". Can someone post or point me to a clear, concise
explanation of it -- one that includes situational examples of how and
why it is used? The Access on-line help is not as helpful as I need
for my mental density!


David nailed it (almost) for giving up CPU time to other apps in Windows
3.x but additionaly and more importantly nowadays, it allows other
events within the same application to run, e.g. Timer events, Mouse
Click and keypress events, repainting, etc. try this on a command button
(with the caption set to "Start":

(air code)
Sub cmdStart_Click()
Static sfRunning As Boolean
Dim l As Long
With cmdStart
if sfRunning then
.Caption = "Start"
sfRunning=False
else
.Caption = "Stop"
sfRunning = True
Do while sfRunning
l = l + 1
Me!txtTextBox.Value = l
DoEvents
Loop
End With
End Sub

Press the Start button and watch the textbox (txtTextBox) count up fast,
press same button (now labelled "Stop") to stop it.

Now take Doevents out, you won't see the caption on the button change or
the textbox count up, neither will you be able to stop it (unless you
Ctrl+Break)

--

\\\\\\
\\ \\ Windows is searching
\ \ For your sig.
\ \ Please Wait.
\__\

Nov 13 '05 #4
Thanks!
David

Nov 13 '05 #5

Awesome! Thanks Arno.
On Wed, 29 Sep 2004 20:44:56 +0200, "Arno R"
<ar****************@tiscali.nl> wrote:
From the Access Cookbook (Getz-Litwin-Baron):
"Sometimes Access seems to come to a halt... Effective use of DoEvents can make the difference ..."

Make a testform with a button cmdDoEvents and a label lblGrow (backgroundcolor as you like)
Code:
Private Sub cmdDoEvents_Click()
Dim intI As Integer
Me!lblGrow.Width = 500
For intI = 0 To 2500 Step 1
Me!lblGrow.Width = Me!lblGrow.Width + 1
'Me.Repaint
DoEvents
Next intI
End Sub

Try to push the button with and without the line DoEvents
(Without DoEvents use Me.Repaint to see the screen repaint).

The difference is when for instance you try to move the form.
-- When you don't use DoEvents you can't move the form WILE the code is running.
Your 'movement' (or other mouseclicks) will be executed AFTER the code is finished.
--When you use DoEvents you can smoothly move the form (code waits until you are done)

Sometimes this can make the difference indeed ...

HTH
Arno R

"Lauren Wilson" <???@???.???> schreef in bericht news:hn********************************@4ax.com...
Hello group,

Somehow, I have not yet fully understood the meaning and purpose of
"DoEvents". Can someone post or point me to a clear, concise
explanation of it -- one that includes situational examples of how and
why it is used? The Access on-line help is not as helpful as I need
for my mental density!

Sorry to be so dense. Please indulge me.

Thanks,

--LW


Nov 13 '05 #6

Thanks Trevor. You are one of the reasons I come to this group. Your
tireless contributions are much appreciated.

On Wed, 29 Sep 2004 20:24:20 +0100, Trevor Best <nospam@localhost>
wrote:
Lauren Wilson wrote:
Hello group,

Somehow, I have not yet fully understood the meaning and purpose of
"DoEvents". Can someone post or point me to a clear, concise
explanation of it -- one that includes situational examples of how and
why it is used? The Access on-line help is not as helpful as I need
for my mental density!


David nailed it (almost) for giving up CPU time to other apps in Windows
3.x but additionaly and more importantly nowadays, it allows other
events within the same application to run, e.g. Timer events, Mouse
Click and keypress events, repainting, etc. try this on a command button
(with the caption set to "Start":

(air code)
Sub cmdStart_Click()
Static sfRunning As Boolean
Dim l As Long
With cmdStart
if sfRunning then
.Caption = "Start"
sfRunning=False
else
.Caption = "Stop"
sfRunning = True
Do while sfRunning
l = l + 1
Me!txtTextBox.Value = l
DoEvents
Loop
End With
End Sub

Press the Start button and watch the textbox (txtTextBox) count up fast,
press same button (now labelled "Stop") to stop it.

Now take Doevents out, you won't see the caption on the button change or
the textbox count up, neither will you be able to stop it (unless you
Ctrl+Break)


Nov 13 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

11
by: Kamus of Kadizhar | last post by:
I have the following function which generates MD5 hashes for files on a local and remote server. The remote server has a little applet that runs from inetd and generates an MD5 hash given the file...
1
by: Steve Jorgensen | last post by:
I know some of you here were following involved with, or annoyed with the volume of traffic in the recent thread I started called "Open Question...". I'm posting this message because, though I...
7
by: Rich | last post by:
Hi, I'm having problems with changing the Read Only properties. Running Winxp and i cannot get the "read only" to clear off a folder. The folder is one that i want to change the data in and it...
145
by: Sidney Cadot | last post by:
Hi all, In a discussion with Tak-Shing Chan the question came up whether the as-if rule can cover I/O functions. Basically, he maintains it can, and I think it doesn't. Consider two...
4
by: Daniel Greene | last post by:
Dear Group, I haven't been on this newsgroup in years. Hello again to village elders Lars Eighner, Alan Flavelle, and Jukka Korpela! :-) What brings me back? I was using the W3C QA to validate...
206
by: WaterWalk | last post by:
I've just read an article "Building Robust System" by Gerald Jay Sussman. The article is here: http://swiss.csail.mit.edu/classes/symbolic/spring07/readings/robust-systems.pdf In it there is a...
13
by: Sunbags | last post by:
Hello, I'm a 2nd year Computer Engineering student and I have a problem with my VB6 code. I've just started learning VB6 for a project in which we have to create a form which displays the...
9
by: Alexnb | last post by:
Okay, so lets say you have a list: funList = and you do: for x in funList: print x this will print 1-5
1
by: robotlizz | last post by:
Hello - I am a brand new at Java and I am having a hard time with a program I have to turn in tomorrow. I can not get the 'Q' option to work and the loop goes on forever. I've tried to go over the...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.