What does the ampersand character and $ mean in the following contexts?

I look through the code and come across this:

Dim lngLen As Long lngLen = 16& 

I did some reading, and it looks like this is a way to drop the number to the end - is that right?

But this is really necessary here, since you can simply assign lngLen to 16 because it is a numeric value.

In addition, after this code, this is done:

 Dim strCompName As String strCompName = String$(lngLen, 0&) 

I understand the String method, from Access help definitions, "returns a variant containing a repeating string of characters of a specified length."

So what does $ do? And again there is and drops 0 to long?

+4
source share
2 answers

Hi, you can check this question for a possible answer to your request.

Edit: Moreover, I was able to scour the Internet for additional resources, and I found this VBA input agreement , which was originally found on this forum page .

Hope this helps you.

+4
source

Good at your request

Some people think that choosing a function that returns the correct type will be somewhat more efficient, and this will speed up code execution.

Well, on the other hand, some people think that it is not useful for the purpose to add the type declaration suffix in the code when it was not declared with the suffix. Sure, it does nothing, code.

 String$ is a function The $ at the end is a way of declaring the variable As String. The & at the end is a way of declaring the variable As Long. 

You are right, I do not think it is necessary here.

+3
source

All Articles