Share via


ULong Data Type (Visual Basic)

Holds unsigned 64-bit (8-byte) integers ranging in value from 0 through 18,446,744,073,709,551,615 (more than 1.84 times 10 ^ 19).

Remarks

Use the ULong data type to contain binary data too large for UInteger, or the largest possible unsigned integer values.

The default value of ULong is 0.

Programming Tips

  • Negative Numbers. Because ULong is an unsigned type, it cannot represent a negative number. If you use the unary minus (-) operator on an expression that evaluates to type ULong, Visual Basic converts the expression to Decimal first.

  • CLS Compliance. The ULong data type is not part of the Common Language Specification (CLS), so CLS-compliant code cannot consume a component that uses it.

  • Interop Considerations. If you are interfacing with components not written for the .NET Framework, for example Automation or COM objects, keep in mind that types such as ulong can have a different data width (32 bits) in other environments. If you are passing a 32-bit argument to such a component, declare it as UInteger instead of ULong in your managed 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 ULong argument to an Automation component on these platforms.

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

  • Type Characters. Appending the literal type characters UL to a literal forces it to the ULong data type. ULong has no identifier type character.

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

See Also

Tasks

How to: Call a Windows Function that Takes Unsigned Types

Concepts

Efficient Use of Data Types

Reference

Data Type Summary (Visual Basic)

UInt64

Type Conversion Functions

Conversion Summary