Name

VarIsEmpty Function

Syntax

function VarIsEmpty(const V: Variant): Boolean;

Description

VarIsEmpty returns True if the Variant V has the varEmpty type, and it returns False for any other kind of Variant. A Variant’s initial type is varEmpty.

VarIsEmpty is a real function.

Example

// Convert a Variant to a TDateTime, but if the Variant
// does not have a value, return the current date and time.
function GetDate(V: Variant): TDateTime;
begin
  if VarIsEmpty(V) or VarIsNull(V) then
    Result := Now
  else
    Result := VarToDateTime(V);
end;

See Also

Unassigned Variable, VarClear Procedure, Variant Type, VarIsNull Function, VarType Function

Get Delphi in a Nutshell now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.