Variants

Variants were first introduced in version 2 of Visual Basic as a flexible data type that could hold each of the simple data types. This data type was extended substantially with Visual Basic 4 to include objects and arrays in particular and a little further with Visual Basic 5 to include the decimal data type. I find it interesting that the decimal data type is the first data type that is not available as a first-class data type—it is available only within a Variant.

A variety of functions will convert and test for these subtypes. Table 5-1 on page 216 shows the development of the Variant through the versions.