What does the $ symbol do in VBA?

后端 未结 5 1875
梦如初夏
梦如初夏 2020-12-04 16:15

For example:

variable1=Dir$(some_path)

vs.

variable1=Dir(some_path)

What is the difference?

Why n

相关标签:
5条回答
  • 2020-12-04 16:17

    Here is a Cheat Sheet for DataTypes

    Variable End with:

    $ : String
    % : Integer (Int16)
    & : Long (Int32)
    ! : Single
    # : Double
    @ : Decimal
    

    Start with:

    &H : Hex
    &O : Octal
    

    Comparison between VB and VB.Net (reference)

    Visual Studio .Net added Literal Types (reference)

    Value End with: (For more complete list, refer the the reference)

    S : Short (Int16)
    I : Integer (Int32)
    L : Long (Int64)
    F : Single
    R : Double
    D : Decimal
    
    0 讨论(0)
  • 2020-12-04 16:19

    I think that the $ version returns a String, and the non $ version returns a variant.

    Mid vs Mid$

    http://forums.devarticles.com/microsoft-access-development-49/mid-function-vs-mid-26315.html

    0 讨论(0)
  • 2020-12-04 16:40

    The dollar sign indicates a string will be returned instead of a variant.

    0 讨论(0)
  • 2020-12-04 16:40

    Dir() returns the result as the variant data type. Dir$() returns the result as the string data type.

    0 讨论(0)
  • 2020-12-04 16:42

    some uses $ version for its purported efficiency(as it accepts and outputs statically-typed variables only). I don't know how much is the speed difference between statically-typed and variant type, just benchmark

    0 讨论(0)
提交回复
热议问题