A variable that has no value Variants unit
  var Null : Variant;
The Null variable has an undefined value.
Null does not mean a zero number or empty string - it is undefined. Any expression using a null variable will yield a null result.
Null is particularly useful when handling SQL table data - providing a one for one correspondence with the SQL NULL value.
The Null variable is the Null Variant.

Calculations using nulls yield the EVariantError.
Related commands
Pointer Defines a general use Pointer to any memory based data
Variant A variable type that can hold changing data types
 Author links

 Buy Website Traffic at

 Buy Proxies at
 Download this web site as a Windows program.

Example code : Using Null to represent the result of a bad divide
  Answer : Variant;

  Answer := Divide(4,2);

  // Show the result of this division
  if Answer = Null
  then ShowMessage('4 / 2 = Invalid')
  else ShowMessage('4 / 2 = '+IntToStr(Answer));

  Answer := Divide(4,0);

  // Show the result of this division
  if Answer = Null
  then ShowMessage('4 / 0 = Invalid')
  else ShowMessage('4 / 0 = '+IntToStr(Answer));


function TForm1.Divide(Dividend, Divisor: Integer) : Variant;
  // Try to divide the Dividend by the Divisor
    Result := Dividend div Divisor;
    Result := Null ;    // Assign Null if the division threw an error
Show full unit code
   4 / 2 = 2
   4 / 0 = Invalid
Delphi Programming Neil Moffatt 2002 - 2017. All rights reserved.  |  Home Page