Declaration shortcuts

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • danp129
    Recognized Expert Contributor
    • Jul 2006
    • 323

    Declaration shortcuts

    I've been doing this for a long time in vb6 but don't see other's using it much...

    Dim a! ' same as Dim a as Short
    Dim b@ ' same as Dim b as Currency
    Dim c# ' same as Dim c as Double
    Dim d$ ' same as Dim d as String
    Dim e% ' same as Dim e as Integer
    Dim f& ' same as Dim f as Long
  • vijaydiwakar
    Contributor
    • Feb 2007
    • 579

    #2
    Originally posted by danp129
    I've been doing this for a long time in vb6 but don't see other's using it much...

    Dim a! ' same as Dim a as Short
    Dim b@ ' same as Dim b as Currency
    Dim c# ' same as Dim c as Double
    Dim d$ ' same as Dim d as String
    Dim e% ' same as Dim e as Integer
    Dim f& ' same as Dim f as Long
    No dear
    this is a hidden aspect so every body don't know it
    but I'm using it always

    Comment

    • Killer42
      Recognized Expert Expert
      • Oct 2006
      • 8429

      #3
      The type declaration characters are simply the old way of declaring data types. As far as I know, the only advantage of the newer way (As Long, etc) is that they are much more straightforward to read.

      I used these type characters in various versions of Basic for many years, but I can't remember most of them now (thanks for the handy reference). But there's much less chance of forgetting what "As String" means. Plus, I think that some new types such as Object, Variant and perhaps others, do not have a type declaraction character. Not too surprising, since they're only supported for backward compatibility.

      It's a personal choice how you prefer to code, of course, but I would recommend using the newer method, so that others can read your code.

      Oh, and by the way, VB6 doesn't have a Short data type. That would be Single.

      Comment

      • danp129
        Recognized Expert Contributor
        • Jul 2006
        • 323

        #4
        Originally posted by Killer42
        The type declaration characters are simply the old way of declaring data types. As far as I know, the only advantage of the newer way (As Long, etc) is that they are much more straightforward to read.

        I used these type characters in various versions of Basic for many years, but I can't remember most of them now (thanks for the handy reference). But there's much less chance of forgetting what "As String" means. Plus, I think that some new types such as Object, Variant and perhaps others, do not have a type declaraction character. Not too surprising, since they're only supported for backward compatibility.

        It's a personal choice how you prefer to code, of course, but I would recommend using the newer method, so that others can read your code.

        Oh, and by the way, VB6 doesn't have a Short data type. That would be Single.
        Oops dunno why I typed short :P

        Comment

        • Killer42
          Recognized Expert Expert
          • Oct 2006
          • 8429

          #5
          Originally posted by danp129
          Oops dunno why I typed short :P
          Been dabbling in other languages, have we? Traitor... ;)

          Comment

          Working...