Results 1 to 3 of 3
  1. #1
    3 Star Lounger
    Join Date
    Dec 2000
    Location
    NJ, USA
    Posts
    239
    Thanks
    2
    Thanked 1 Time in 1 Post

    Dim ....&, Dim ...%

    In the "old" style of declaring variables (using a character suffix) what did "&" signify? How about "%"?

    Thanks.

  2. #2
    Platinum Lounger
    Join Date
    Dec 2000
    Location
    Queanbeyan, New South Wales, Australia
    Posts
    3,730
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Dim ....&, Dim ...%

    & is long
    % is integer
    $ is string

    As in this example:
    <pre>Dim i&
    Dim j%
    Dim k$
    Dim v As Variant
    v = i
    Debug.Print TypeName(v)
    v = j
    Debug.Print TypeName(v)
    v = k
    Debug.Print TypeName(v)
    </pre>


    The only time I use any of the above is "$" for string in functions which return strings:

    strString = mid$(strOtherString,4,2))

    This makes it slightly faster, as the function does not have to perform a variant-to-string conversions when assigning it to strString.

    Of course, the situation where it makes any real difference at all is probably rare.
    Subway Belconnen- home of the Signboard to make you smile. Get (almost) daily updates- follow SubwayBelconnen on Twitter.

  3. #3
    3 Star Lounger
    Join Date
    Dec 2000
    Location
    NJ, USA
    Posts
    239
    Thanks
    2
    Thanked 1 Time in 1 Post

    Re: Dim ....&, Dim ...%

    Thanks. I use the "As Integer" (etc.) format, but ran across somebody else's (probably old) code using the suffix syntax and was curious.
    I had read some previous discussions a while back about the slight speed improvement of Mid$() over Mid(). As you say, I think the conclusion was that the improvement was so marginal that it wouldn't be noticed unless it were inside a loop that was executing hundreds (or thousands?) of times.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •