Long Data Type (Visual Basic)


Updated: July 20, 2015

For the latest documentation on Visual Studio 2017 RC, see Visual Studio 2017 RC Documentation.

Holds signed 64-bit (8-byte) integers ranging in value from -9,223,372,036,854,775,808 through 9,223,372,036,854,775,807 (9.2...E+18).

Use the Long data type to contain integer numbers that are too large to fit in the Integer data type.

The default value of Long is 0.

  • Interop Considerations. If you are interfacing with components not written for the .NET Framework, for example Automation or COM objects, remember that Long has a different data width (32 bits) in other environments. If you are passing a 32-bit argument to such a component, declare it as Integer instead of Long in your new Visual Basic code.

    Furthermore, Automation does not support 64-bit integers on Windows 95, Windows 98, Windows ME, or Windows 2000. You cannot pass a Visual Basic Long argument to an Automation component on these operating systems.

  • Widening. The Long data type widens to Decimal, Single, or Double. This means you can convert Long to any one of these types without encountering a System.OverflowException error.

  • Type Characters. Appending the literal type character L to a literal forces it to the Long data type. Appending the identifier type character & to any identifier forces it to Long.

  • Framework Type. The corresponding type in the .NET Framework is the System.Int64 structure.

Data Types
Integer Data Type
Short Data Type
Type Conversion Functions
Conversion Summary
Efficient Use of Data Types