473,545 Members | 2,047 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 37196
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 (backgroundcolo r as you like)
Code:
Private Sub cmdDoEvents_Cli ck()
Dim intI As Integer
Me!lblGrow.Widt h = 500
For intI = 0 To 2500 Step 1
Me!lblGrow.Widt h = Me!lblGrow.Widt h + 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.c om...
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.V alue = 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 (backgroundcolo r as you like)
Code:
Private Sub cmdDoEvents_Cli ck()
Dim intI As Integer
Me!lblGrow.Wid th = 500
For intI = 0 To 2500 Step 1
Me!lblGrow.Widt h = Me!lblGrow.Widt h + 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.c om...
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@localho st>
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.V alue = 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
2373
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 name. The problem is that it takes 2+ minutes to generate the MD5 hash, so this function takes about 5 minutes every time it is called. Since...
1
1540
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 don't think anyone was terribly angry or inflamed, there are things I don't like about how I conducted myself in the discussion. I would like to...
7
15009
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 won't let me. I have two accounts on the main system and cannot change the properties from either administrator account. I have tried renaming the...
145
6172
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 programs: /*** a.c ***/
4
2117
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 my XHTML the other day, and I came across this "tip of the day" called "Use standard redirects: don't break the back button!" It said, "If you want...
206
8176
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 footprint which says: "Indeed, one often hears arguments against building exibility into an engineered sys- tem. For example, in the philosophy of...
13
17918
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 knight-rider light sequence. Obviously, this means using a loop and our lecturer has told us to use timers to control how long the sequence lasts for. I don't...
9
1556
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
4574
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 tutorials but when I change it from here I then get compiling issues... Can someone explain what I've done wrong? import javax.swing.JOptionPane;...
0
7475
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7664
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
1
7436
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7766
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
5981
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5341
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
4958
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3463
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3446
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.