Symbolic string declaration versus not

conception_native_0123

Well-known member
Local time
Today, 07:27
Joined
Mar 13, 2021
Messages
1,923
I ran into this post tonight and I've always wondered about this...


Arne used it in the function example he posted. Can someone tell me why it even matters that I would suffix the format function with the dollar sign or not? If I'm not mistaken, in VBA, the dollar sign is a literal declaration symbol to make sure that an input or an output is a string. Is that correct? In other words why would I care to do this: format$(), when this has always given me everything I needed? Format()??

Thanks.
 
VBA Developer's Handbook
2nd Edition
by:
Ken Getz
Mike Gilbert

pg.38
About the Functions Ending in $
VBA supplies all the functions that return strings in two formats—one with a dollar sign ($)
at the end and one without. Why did they bother? The versions without $s return variants,
and the ones with $s return strings. The variant versions are able to propagate a null value
through an expression; the string functions cannot. That is, if the input value is a variant
containing Null, the variant functions return Null, and the string functions trigger a run-
time error. The string functions, on the other hand, are faster; because they don’t need to
perform any data type conversions, they can do their work faster.

How do you decide which version to use? If you’re concerned about wringing the best
performance out of your application and you can ensure that you won’t be sending null
values to these functions, by all means, use the string-specific version of any function you can.
 
well arne,

thanks so much for the precise response. I can't ask for anything better than that! much appreciative am I of you and your post. :) gracie.
 

Users who are viewing this thread

Back
Top Bottom