Skip to main content

varWord

varWord = 18

Example

function HasUnsigned16Storage(const Value: Variant): Boolean;
begin
Result := (VarType(Value) and varTypeMask) = varWord;
end;

Usage

varWord identifies an unsigned 16-bit Variant integer whose upper half exceeds signed SmallInt range.

Additional Technical Info

varWord is the base TVarType code $0012 for an unsigned 16-bit integer (0..65,535).

It is distinct from signed varSmallInt: values 32,768..65,535 require the unsigned range, while negative values cannot be Word. Delphi's packed Variant creation can choose varByte for smaller unsigned values, so exact tags vary with source and range.

VarAsType with varWord narrows/converts the source. Validate that the value is integral and within range; negative, fractional, invalid-text or oversized input can round, reject or raise a Variant conversion/range/overflow exception.

Current Delphi Automation dispatch can remap Word arguments to a signed varSmallInt code when the host-global DispatchUnsignedAsSigned compatibility setting is enabled. Values above 32,767 cannot preserve meaning through that remapping; make the external interface's signedness explicit.

VarType only reads the raw tag. Mask flags before base comparison.

The example is source-reviewed only; no unsigned conversion or dispatch occurred.

External references

Created 2026-07-15