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!:p
Printable View
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!:p
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
Thanks Olly!
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:
That way you will see all updates.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
yeah, i think so as well, but... long ago, u know ;) not entirely sure
Inside as you want to check for messages between each loop
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
DoEvents
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...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
A simple optimising trick that will make your program run faster and be a more friendly windows citizen :D
Basically, it stops your App from freezing, because it processes other tasks.