From RAD Studio API Documentation
Jump to: navigation, search


function VarConvertCreate(const AValue: Double; const AType: TConvType): Variant;
function VarConvertCreate(const AValue: string): Variant;


extern DELPHI_PACKAGE System::Variant __fastcall VarConvertCreate(const double AValue, const System::Convutils::TConvType AType)/* overload */;


Type Visibility Source Unit Parent
function public
System.VarConv System.VarConv


Returns a custom Variant that represents a measurement.

Call VarConvertCreate to create a Variant whose value is a measurement.

Using the first syntax, AType indicates the measurement units, and AValue is the number of those units. AType must represent a registered conversion unit.

Using the second syntax, AValue is a string that can be parsed by the TryStrToConvUnit function. (For example '1.5 liters'.)

If the string can't be parsed into a measurement, VarConvertCreate raises an EInvalidCast exception.

VarConvert custom Variants represent measurements (that is, a type of measurement units and the number of those units). The units must be registered measurement units such as those used by the ConvUtils unit. You can use the negation operator on VarConv variants, and use the addition, subtraction, multiplication, division, and comparison operators on a VarConv Variant with a real number. You can use the addition, subtraction, division, and comparison operators on two VarConv Variants.

VarConv custom Variants also support the following properties:

  • Value is the numeric portion (the number of units). (read/write)
  • Type is units. (read-only)
  • TypeName is the name of the units. (read-only).
  • Family is the conversion family of the units (the thing measured). (read-only).
  • FamilyName is the name of the conversion family. (read-only)

Depending on the Family, each Variant has a set of conversion properties with names of the form As<Unit>, where <Unit> is the name of another type of unit in the same conversion family.

See Also