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 6 37179
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
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
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.
\__\
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
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) This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
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...
|
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...
|
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...
|
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...
|
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...
| |
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...
|
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...
|
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
|
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...
|
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,...
|
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,...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
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...
|
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...
|
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...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...
| |