PrintVarType (Delphi)
Description
This example demonstrates the use of the VarType and VarTypeAsText methods defined in the Variants unit.
Code
var
LVar: Variant;
begin
{ Assign a byte value to the variant. }
{ Prints out "Byte" to the console. }
LVar := 100;
Writeln(VarTypeAsText(VarType(LVar)));
{ Multiply the byte value by 1000. This results in an Int64 with a value of 100000. }
{ Prints out "Int64" to the console. }
LVar := LVar * 1000;
Writeln(VarTypeAsText(VarType(LVar)));
{ Divide the LongWord value by 5.0. This results in a double value. }
{ Prints out "Double" to the console. }
LVar := LVar / '5.0';
Writeln(VarTypeAsText(VarType(LVar)));
Readln;
end.
Uses
- System.Variants.VarTypeAsText ( fr | de | ja )
- System.Variants.VarType ( fr | de | ja )