|
-
Apr 29th, 2001, 06:09 AM
#1
Thread Starter
Junior Member
Alright Dudes: how to use DoEvents?
You all mentioned I should use DoEvents, but what I could really do with is an example of how to implement this because - you guessed it - I am that complete VB 6.0 newbie which gets on everybody's nerves...
Thanks!
-
Apr 29th, 2001, 06:15 AM
#2
Registered User
Private Sub Form_Load()
Dim x As Integer
DoEvents
For x = 1 To 10000
progrsssbar = progressbar + 1 'or something like that
Next
'because of the doevents it will still refresh the prograss bar and you'll be able to see the changes
End Sub
-
Apr 29th, 2001, 06:21 AM
#3
Thread Starter
Junior Member
-
Apr 29th, 2001, 06:27 AM
#4
Thats not entirely true.
If you use the supplied code, you will only clear the message stack once. If you are going to use it, it should be:
Code:
Private Sub Form_Load()
Dim x As Integer
For x = 1 To 10000
progrsssbar.value = progressbar.value + 1 'or something like that
DoEvents
Next x
End Sub
That way you will see all updates.
-
Apr 29th, 2001, 06:31 AM
#5
Registered User
yeah, i think so as well, but... long ago, u know not entirely sure
-
Apr 29th, 2001, 07:06 AM
#6
_______
<?>
Inside as you want to check for messages between each loop
"A myth is not the succession of individual images,
but an integerated meaningful entity,
reflecting a distinct aspect of the real world."
___ Adolf Jensen
-
Apr 29th, 2001, 08:38 AM
#7
Code:
Private Sub Form_Load()
Dim x As Integer
For x = 1 To 10000
progrsssbar.value = progressbar.value + 1 'or something like that
DoEvents
Next x
End Sub
This code will bring your computer to a crawl (well, not quite) because doevents lets all outstanding events happen. If you must use it in a loop then let it fire once every few hundred cycles of the loop by using a MOD statement...
Code:
Private Sub Form_Load()
Dim x As Integer
For x = 1 To 10000
progrsssbar.value = progressbar.value + 1 'or something like that
If (x mod 200) = 0 Then DoEvents 'if x is a multiple of 200
Next x
End Sub
this will let your code do rapid bursts of work and then check for events, and then another rapid burst etc...
A simple optimising trick that will make your program run faster and be a more friendly windows citizen
-
Apr 29th, 2001, 10:03 AM
#8
Basically, it stops your App from freezing, because it processes other tasks.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|