Variant type
From Wikipedia, the free encyclopedia
Variant is a type of data in certain programming languages.
In VBA and VB Variant data type can be used to represent any other data type (e.g. integer, floating-point, single- and double-precision, object, etc.) except fixed-length string type.
In VBA/VB any variable, not declared explicitly, is taken to be of Variant type and called for brevity 'a variant'. While the use of variants in general (and especially of not explicitly declared variants) is not recommended, variants can provide sometimes a 'quick-and-dirty' way around error messages associates with converting one data type into another. This is so because a variant can be assigned a value of any type and it can take the value of any other variable declared as of a different type.
In VBA/VB a variant named A can be explicitly declared as shown in these two examples:
Dim A
Dim A as Variant