philfer
11-10-2008, 07:35 AM
I have this test code for DoEvents
Private Sub CommandButton1_Click()
Dim lngIndex As Long
For lngIndex = 1 To 9999
Label1.Caption = lngIndex
Next
Label1.Caption = "Done"
End Sub
Private Sub CommandButton2_Click()
Dim lngIndex As Long
For lngIndex = 1 To 9999
Label1.Caption = lngIndex
DoEvents
Next
Label1.Caption = "Done"
End Sub
And the version with DoEvents takes about twice as long to run
Does it really slow it down that much?
Why is that? Is it because it keeps passing control back to the op sys and taking it back
If so, whats really the point of using DoEvents as you are just making your macro slow, n'est pas?
Thanks
Phil
Private Sub CommandButton1_Click()
Dim lngIndex As Long
For lngIndex = 1 To 9999
Label1.Caption = lngIndex
Next
Label1.Caption = "Done"
End Sub
Private Sub CommandButton2_Click()
Dim lngIndex As Long
For lngIndex = 1 To 9999
Label1.Caption = lngIndex
DoEvents
Next
Label1.Caption = "Done"
End Sub
And the version with DoEvents takes about twice as long to run
Does it really slow it down that much?
Why is that? Is it because it keeps passing control back to the op sys and taking it back
If so, whats really the point of using DoEvents as you are just making your macro slow, n'est pas?
Thanks
Phil