VBA overflow of long data type

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • srj115
    New Member
    • Sep 2007
    • 9

    VBA overflow of long data type

    I've been messing with an Access database recently. I'm trying to assign a 14-digit number to a long variable, and I keep getting an overflow message!

    Code:
    Dim lng as Long
    lng = 20081008095613#
    I don't get the overflow when using a double, but later I'm going to convert the value into a string. (I can't have that goofy "+E18" value at the end.)

    Why does VBA automatically add that "#" symbol to the end? Why am I getting an overflow? I thought longs were able to hold up to +-9,223,372,036,8 54,775,808.
  • ubentook
    New Member
    • Dec 2007
    • 58

    #2
    A Long covers the range from...
    -2,147,483,648 to 2,147,483,647

    The # symbol is the type-declaration character that indicates the number is a Double.

    You could declare the number as a String and then convert it to a Double when necessary or simply use two different variables - a String and a Double.

    Comment

    • srj115
      New Member
      • Sep 2007
      • 9

      #3
      Originally posted by ubentook
      A Long covers the range from...
      -2,147,483,648 to 2,147,483,647

      The # symbol is the type-declaration character that indicates the number is a Double.

      You could declare the number as a String and then convert it to a Double when necessary or simply use two different variables - a String and a Double.
      32-bit... My mistake. Thank you!

      Comment

      Working...