I just found the below line of code in a project I am working on. I have never seen functions with the $
I found online that it is a vb string function. The page said the "Right$" is more efficient than simply writing "Right"
So is this still current with the most up to date vb language features or is it deprecated?
Right$(sNumToBeFormatted, 8)
I found online that it is a vb string function. The page said the "Right$" is more efficient than simply writing "Right"
VB6 had (and VBA still has) two versions of many string functions.
One version accepted and returned String
s, another one accepted and returned Variant
s. The string versions had $
in their name to make them stand out.
One cannot say that using Right$
is always better than using Right
. It depends on the type of your source and result data.
If you receive data as Variant
s and send it out as Variant
s, like e.g. Excel does, using Right
will result in fewer conversions between String
and Variant
.
If your data is originally a String
, using Right$
is better.
So is this still current with the most up to date vb language features or is it deprecated?
VB.NET only includes the typed versions, but it does not show the $
anymore.
So Right$
is the up to date version, but it was renamed to simply Right
. There is no choice anymore.
There is still choice in VBA, where both versions are valid and supported.
$
sign means that returned value of Right
will be string
You can also do this
Dim someString$
which is equivalent to
Dim someString as String
For more go here
As to this question
So is this still current with the most up to date vb language features
or is it deprecated?
There is nothing stopping you from using it as it is supported, but because it is not popular at all it shouldn't be so next person reading code wont be going over it like you are at the moment.
This syntax was already optional in vb6.