The magic $
Many of you will have noticed that there is both a Mid and a Mid$ function,
as well as Left$, Right$, and a number of other functions. However, it is not
obvious what the difference actually is. When you use the Mid function, it returns
a string as a Variant data type. As you would normally save the result to a
string, not a Variant, Visual Basic then has to convert the Variant into a string.
When you use the Mid$ function, it returns a string in a String variable. This
saves Visual Basic the trouble of converting the Variant to a String, and thus
increases performance. When you perform long loops of code, using Mid, and the
other string functions, this can make quite a difference. I have yet to find
an instance when you would actually want the Mid statement to return a Variant,
and not a String, so I am not sure why Microsoft have done this. To see a list
of all the procedures that have a $ (string) version as well, open the object
browser (F2), enter $ into the find box, and press Find. This will give you
a list of about 25 procedures where this is the case.