Variant data do not conform to a specific data type and can contain attributes. LabVIEW represents variant data with the variant data type. The variant data type differs from other data types because it stores the control or indicator name, information about the data type from which you converted, and the data itself, which allows LabVIEW to correctly convert the variant data type to the data type you want. For example, if you convert a string data type to a variant data type, the variant data type stores the text and indicates that the text is a string.
Use the Variant functions to create and manipulate variant data. You can convert any LabVIEW data type to the variant data type to use variant data in other VIs and functions. Several polymorphic functions return the variant data type.
Use the variant data type when it is important to manipulate data independently of data type, such as when you transmit or store data; read and/or write to unknown devices; or perform operations on a heterogeneous set of controls.
For example, use the variant data type when working with ActiveX objects that require a variant data type. You also can use the variant data type with control references to read or modify values of a programmatically selected control.
You also can use the Flatten To String function to convert a data type to a string data type to represent data independently of type. Flattening data to strings is useful when you use TCP/IP to transmit data because the protocol understands only strings. However, using flattened data has limitations because LabVIEW cannot coerce flattened data when the original data type does not match the data type to which you want to convert. You cannot flatten ActiveX variant data. Also, attempting to unflatten a flattened integer as an extended-precision floating-point number fails.
Another advantage of using the variant data type is the ability to store attributes of the data. An attribute is information about the data that you define and the variant data type stores. For example, if you want to know the time when a piece of data was created, you can store the data as variant data and add an attribute called Time to store the time string. The attribute data can be of any type. Use variant attributes when you want to sort the data by a particular attribute, identify the device or application that generated the data, or filter the data for only those variants with a particular attribute.