PrintVarType (C++)

From RAD Studio Code Examples
Jump to: navigation, search

Description

This example demonstrates the use of the VarType and VarTypeAsText methods defined in the Variants unit.

Code

int _tmain(int argc, _TCHAR* argv[])
{
	/* Assign a byte value to the variant.
	   Prints out "Byte" to the console. */
	Variant var(100);
	printf("%ls\n", VarTypeAsText(VarType(var)).c_str());

	/* Multiply the byte value by 1000. This results in an Int64 with a value
	   of 100000. Prints out "Int64" to the console. */
	var *= 1000;
	printf("%ls\n", VarTypeAsText(VarType(var)).c_str());

	/* Divide the LongWord value by 5.0. This results in a double value.
	   Prints out "Double" to the console. */
	var /= "5.0";
	printf("%ls\n", VarTypeAsText(VarType(var)).c_str());
}

Uses