Thread: branching macro
View Single Post
  #13   Report Post  
Posted to microsoft.public.excel.programming
Jim Thomlinson Jim Thomlinson is offline
external usenet poster
 
Posts: 5,939
Default branching macro

I always use the Call keyword to document my code. That makes it obvious what
that line of code is doing. With no appreciable difference between the two
methods I will stick with Call. Thank Jim...
--
HTH...

Jim Thomlinson


"Jim Cone" wrote:


I ran my own code using "timeGetTime" over 100,000 loops.
"Call" averaged 48 milliseconds.
Without "Call" averaged 48 milliseconds. (identical result)
Each version was run 20 times.

Also, Call is self documenting.
--
Jim Cone
San Francisco, USA
http://www.realezsites.com/bus/primitivesoftware
(Excel Add-ins / Excel Programming)





"Jim Thomlinson"

wrote in message
I was not doubting you I was just curious. When I tested it I found no
appreciable difference so I was wondering if there was any kind of info on
it. I like knowing what the compiler is up to and what will generate more
efficient code...

Sub TimeTest()
Dim lng As Long
Dim dblStartTime As Double
Dim dblEndTime As Double
Const lngLoops As Long = 100000000

dblStartTime = Timer
For lng = 1 To lngLoops
Call DoStuff
Next lng
dblEndTime = Timer
MsgBox "Duration " & dblEndTime - dblStartTime

dblStartTime = Timer
For lng = 1 To lngLoops
DoStuff
Next lng
dblEndTime = Timer
MsgBox "Duration " & dblEndTime - dblStartTime

End Sub
Sub DoStuff()
Dim x As Long
x = 1
End Sub
--
HTH...
Jim Thomlinson