Summary
To summarize this simple tutorial, I would like to suggest the following few
things to think of.
-
ByRef is faster to call, and it is the default for a good reason.
- Use
ByRef if the value is very long. Why use a copy of a very
long string, when all you need to do is use the memory address location?
- When using multiple options, order them
ByRef, ByVal,
Optional.
- Evaluate if a Constant will be constant at all times or if you can save your
self re-coding hassles by using default Optional arguments.
- Come to think of it, did I just manage to make constants less constant or
what?
An a final note to something I have often found out the hard way in all of
my coding and after pounding out perfect code that never works as fast anywhere
else as on my own computer.
Test, try, twist and turn, because no matter how much you learn form reading,
the final speed check really comes around when you try the code and add a few
timers to test it in practical forms.
As I have also learned, it is not always needed to have high speed on all you
do, but if your function is for example used in recursive loops then more than
ever should you look at details.
The number of repetitions will slow down the speed of your application enormously
if you choose the wrong way to do things.