R
RB Smissaert
Read in the book Visual Basic for Applications in 21 days by Matthew Harris
(third edition) that putting the loop counter after the Next would make the
loop faster:
For i = 0 to 10
'code
Next i
I can see it makes the code clearer, but I didn't think it made it any
faster and on simple testing I can see no difference:
Option Explicit
Private lStartTime As Long
Private Declare Function timeGetTime Lib "winmm.dll" () As Long
Sub StartSW()
lStartTime = timeGetTime()
End Sub
Sub StopSW(Optional ByRef strMessage As Variant = "")
MsgBox "Done in " & timeGetTime() - lStartTime & " msecs", , strMessage
End Sub
Sub test()
Dim i As Long
Dim c As Long
Dim n As Long
StartSW
For i = 0 To 10000
For c = 0 To 1000
n = i + c
Next
Next
StopSW
End Sub
Is there any truth in this?
RBS
(third edition) that putting the loop counter after the Next would make the
loop faster:
For i = 0 to 10
'code
Next i
I can see it makes the code clearer, but I didn't think it made it any
faster and on simple testing I can see no difference:
Option Explicit
Private lStartTime As Long
Private Declare Function timeGetTime Lib "winmm.dll" () As Long
Sub StartSW()
lStartTime = timeGetTime()
End Sub
Sub StopSW(Optional ByRef strMessage As Variant = "")
MsgBox "Done in " & timeGetTime() - lStartTime & " msecs", , strMessage
End Sub
Sub test()
Dim i As Long
Dim c As Long
Dim n As Long
StartSW
For i = 0 To 10000
For c = 0 To 1000
n = i + c
Next
Next
StopSW
End Sub
Is there any truth in this?
RBS