What do ! and # mean when attached to numbers in VB6?

后端 未结 3 610
情话喂你
情话喂你 2020-12-15 19:09

I have recently come across numeric literals such as 10! and 50# in Visual Basic programs. Could anyone tell me what these punctuation marks mean?

相关标签:
3条回答
  • 2020-12-15 19:26

    Using these characters specifies the data type of a numeric literal.

    I thought this would be covered in the VB6 manual online but I can't find it.

    However I just proved it with the TypeName function in the VB6 IDE Immediate Window:

    ? typename(10!)
    Single
    ?typename(10#)
    Double
    ?typename(10%)
    Integer
    ?typename(10&)
    Long
    ?typename(10@)
    Currency
    

    PS Be aware that a VB6 Integer is 2 bytes, -32,768 to 32,767.

    0 讨论(0)
  • 2020-12-15 19:33

    ****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-15 19:45

    They are called type declaration characters. This article has more information.

      % Integer
      & Long
      ! Single
      # Double
      $ String
      @ Currency
    
    0 讨论(0)
提交回复
热议问题