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![]()




Reply With Quote