if VarIsNull(resultVariant) then
resultVariant := VarFromDateTime(Now);
type TVarType = Word; Defines the data type used to represent variant type codes.
type TVariantRelationship = (vrEqual, vrLessThan, vrGreaterThan, vrNotEqual); Defines possible outcomes of variant comparison.
| Type | Description |
|---|---|
varEmpty |
The variant is unassigned |
varNull |
The variant is Null |
varAny |
A variant that can hold any value |
varSmallint |
16-bit signed integer (Smallint in Delphi, short in C++) |
varInteger |
32-bit signed integer (Integer in Delphi, int in C++) |
varSingle |
Single-precision floating-point value (Single in Delphi, float in C++) |
varDouble |
Double-precision floating-point value (Double) |
varCurrency |
Currency floating-point value (Currency) |
varDate |
Date and time value (TDateTime) |
varOleStr |
Reference to a dynamically allocated UNICODE string |
varDispatch |
Reference to an Automation object (IDispatch pointer) |
varError |
Operating system error code |
varBoolean |
16-bit Boolean (WordBool) |
varVariant |
Indicates another variant |
varUnknown |
Reference to an unknown object (IUnknown or IInterface pointer) |
varShortInt |
8-bit signed integer (ShortInt or signed char) |
varByte |
8-bit unsigned byte |
varWord |
Unsigned 16-bit value (Word) |
varLongWord |
Unsigned 32-bit value (LongWord or unsigned long) |
varInt64 |
64-bit signed integer (Int64 or __int64) |
varStrArg |
COM-compatible string |
varString |
Reference to a dynamically allocated non-COM string |
varArray |
Indicates a Variant array |
varByRef |
Indicates the variant contains a reference instead of a value |
varTypeMask |
Type mask for array elements |
| Procedure | Description |
|---|---|
function VarType(const V: Variant): TVarType; |
Return the type code of a variant |
function VarAsType(const V: Variant; aVarType: TVarType): Variant; |
Convert a variant to a specific variant type |
function VarIsByRef(const V: Variant): EvalBool; |
Return True if the variant contains a reference |
function VarIsEmpty(const V: Variant): EvalBool; |
Return True if the variant is unassigned |
function VarIsNull(const V: Variant): EvalBool; |
Return True if the variant is Null |
function VarIsClear(const V: Variant): EvalBool; |
Return True if the variant is cleared or uninitialized |
function VarIsError(const V: Variant; out AResult: HRESULT): EvalBool; |
Return True if the variant contains an error value |
function VarAsError(AResult: HRESULT): Variant; |
Create a variant representing a COM error code |
function VarIsCustom(const V: Variant): EvalBool; |
Return True if the variant is of a custom (user-defined) type |
function VarIsOrdinal(const V: Variant): EvalBool; |
Return True if the variant contains an ordinal (integer-like) type |
function VarIsFloat(const V: Variant): EvalBool; |
Return True if the variant contains a floating-point number |
function VarIsNumeric(const V: Variant): EvalBool; |
Return True if the variant contains a numeric type |
function VarIsStr(const V: Variant): EvalBool; |
Return True if the variant contains a string |
function VarIsArray(const A: Variant; AResolveByRef: EvalBool = True): EvalBool; |
Return True if the variant is an array |
function VarToStr(const V: Variant): string; |
Convert a variant to a string |
function VarToStrDef(const V: Variant; ADefault: string): string; |
Convert a variant to a string, returning a default if invalid |
function VarToWideStr(const V: Variant): WideString; |
Convert a variant to a WideString |
function VarToWideStrDef(const V: Variant; ADefault: WideString): WideString; |
Convert a variant to a WideString with default value |
function VarToUnicodeStr(const V: Variant): UnicodeString; |
Convert a variant to a UnicodeString |
function VarToUnicodeStrDef(const V: Variant; ADefault: UnicodeString): UnicodeString; |
Convert a variant to a UnicodeString with default value |
function VarToDateTime(const V: Variant): TDateTime; |
Convert a variant to a TDateTime |
function VarFromDateTime(DateTime: TDateTime): Variant; |
Convert a TDateTime to a variant |
function VarInRange(const AValue, AMin, AMax: Variant): EvalBool; |
Return True if a variant value is within a range |
function VarEnsureRange(const AValue, AMin, AMax: Variant): Variant; |
Clamp a variant to a specified range |
function VarSameValue(const A, B: Variant): EvalBool; |
Return True if two variants have the same value |
function VarCompareValue(const A, B: Variant): TVariantRelationship; |
Compare two variants and return their relationship |
function VarTypeIsValidArrayType(aVarType: TVarType): EvalBool; |
Return True if the type can be used as an array type |
function VarTypeIsValidElementType(aVarType: TVarType): EvalBool; |
Return True if the type can be used as an element type in a variant array |
function VarArrayCreate(Bounds: array of SizeInt; aVarType: TVarType): Variant; |
Create a variant array of the given bounds and element type |
function VarArrayOf(Values: array of Variant): Variant; |
Create a variant array initialized with given values |
procedure VarArrayRedim(var A: Variant; HighBound: SizeInt); |
Change the upper bound of the last dimension in a variant array |
function VarArrayAsPSafeArray(const A: Variant): Pointer; |
Return a pointer to the SAFEARRAY representing the variant array |
procedure VarCopyNoInd(var Dest: Variant; const Source: Variant); |
Copy a variant value without dereferencing references |
function VarArrayDimCount(const A: Variant): SizeInt; |
Return the number of dimensions in a variant array |
function VarArrayLowBound(const A: Variant; Dim: SizeInt): SizeInt; |
Return the lower bound of a specified array dimension |
function VarArrayHighBound(const A: Variant; Dim: SizeInt): SizeInt; |
Return the upper bound of a specified array dimension |
function VarArrayLock(const A: Variant): Pointer; |
Lock a variant array and return a pointer to its data |
procedure VarArrayUnlock(const A: Variant); |
Unlock a previously locked variant array |
function VarArrayRef(const A: Variant): Variant; |
Return a reference to a variant array |
function VarArrayGet(const A: Variant; Indices: array of Int32): Variant; |
Retrieve an element from a variant array by index |
procedure VarArraySet(var A: Variant; const Value: Variant; Indices: array of Int32); |
Assign a value to a variant array element by index |
type HResult = Integer; Defines the 32-bit signed integer type used for COM and Windows API result codes.
| Constant | Value | Description |
|---|---|---|
S_OK |
0 |
No error, the operation succeeded (often interpreted as True) |
S_FALSE |
$00000001 |
No error, but the operation did not produce a meaningful result (often interpreted as False) |
E_NOINTERFACE |
$80004002 |
The requested interface is not supported by the object |
E_UNEXPECTED |
$8000FFFF |
Catastrophic or unexpected failure |
E_NOTIMPL |
$80004001 |
Operation not implemented |
version 7.0.250121
Edit All Pages