Dollar sign after Right/Left function in VBA?

Enigmachrysalis

Active Member
Joined
Apr 13, 2009
Messages
350
I keep seeing Right$(arg,arg) in VBA examples, but I am not sure what the dollar sign is doing.

Is it acting like a string declaration?
 

Excel Facts

Did you know Excel offers Filter by Selection?
Add the AutoFilter icon to the Quick Access Toolbar. Select a cell containing Apple, click AutoFilter, and you will get all rows with Apple
I keep seeing Right$(arg,arg) in VBA examples, but I am not sure what the dollar sign is doing.

Is it acting like a string declaration?

Yep but it is probably unnecesary since it will be coerced to a string anyway. It might be faster with the $ than without.
 
Upvote 0
I've seen the $ sign used too but I've never actually found an adequate explanation f it has advantages or not.

I think basically what the $ does is make the function explicitly return a String variable, whereas without it you get a Variant.

Might be an issue for something but I really can't think what.:)
 
Upvote 0
I believe that was part of the function name (implying it's a string function) in old versions of VB (like VB4)...just a legacy convention from the old version provided today for compatibility.

It's exactly the same as "Right" without the "$"
 
Last edited:
Upvote 0
with respect to data types
@ is currency
# is double
% is integer
& is long
! is single
$ is string
 
Upvote 0
I really wouldn't bother about the difference between Left or Left$ and other similar functions.

Next you'll be dabbling with Len and LenB, and we all know that could lead to.:)
 
Upvote 0
Well, I saw the $ used in some slick code examples in a book I have, so I figured it was worth learning.

So, no luck on the ! character then?
 
Upvote 0
In that link the only thing I can seem to find that uses ! is when using a recordset with ADO.

As far as I'm aware that just something you would use to refer to a field in the recordset.

Perhaps similar to the . (dot qualifier) you use in Excel VBA, which you can also use in Access VBA.

I can't off the top of my head whether there are advantages/disadvantages of using one or the other.:)
 
Upvote 0

Forum statistics

Threads
1,216,731
Messages
6,132,396
Members
449,725
Latest member
Enero1

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top