UInteger Data Type


Updated: July 20, 2015

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

Holds unsigned 32-bit (4-byte) integers ranging in value from 0 through 4,294,967,295.

The UInteger data type provides the largest unsigned value in the most efficient data width.

The default value of UInteger is 0.

The UInteger and Integer data types provide optimal performance on a 32-bit processor, because the smaller integer types (UShort, Short, Byte, and SByte), even though they use fewer bits, take more time to load, store, and fetch.

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

  • CLS Compliance. The UInteger data type is not part of the Language Independence and Language-Independent Components (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 uint can have a different data width (16 bits) in other environments. If you are passing a 16-bit argument to such a component, declare it as UShort instead of UInteger in your managed Visual Basic code.

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

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

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

Data Types
Type Conversion Functions
Conversion Summary
How to: Call a Windows Function that Takes Unsigned Types
Efficient Use of Data Types