Visual Basic

Programming with Variants

Microsoft Visual Basic 6 further enhances the Variant data type from the previous version so that it can now hold user-defined types (UDTs). This creates yet another reason why you should become familiar with Variants and what they can do.

In this tutorial I will take an in-depth look at Variants and discuss the benefits and pitfalls of programming with them.

Variants were first introduced in version 2 of Visual Basic as a flexible data type that could hold each of the simple data types. The Variant data type was extended substantially with version 4 to include Byte, Boolean, Error, Objects, and Arrays, and a little further with version 5 to include the Decimal data type. The Decimal data type was the first data type that was not available as a "first class" data type-it is available only within a Variant-and you cannot directly declare a variable as a Decimal.

by BrainBellupdated
Advertisement: