Universal Data Type Changes for Visual Basic 6.0 Users

Visual Basic 2008 updates the universal data type for interoperability with the common language runtime.

Visual Basic 6.0

In Visual Basic 6.0, Variant serves as the universal data type. This means that you can store data of any type in a variable of type Variant.

Visual Basic 2005

In Visual Basic 2008, Object is the universal data type. A variable of type Object can hold data of any type. The Variant type is not supported, and all its functionality is supplied by Object.

Variant is still a reserved word in Visual Basic 2008, even though it has no syntactical use. This helps avoid confusion with its former meanings.

The VarType function returns a member of the VariantType enumeration that provides the data type classification of an object variable. You can also use classes in the System namespace to obtain numeric data type information for an Object instance, as shown in the following code:

' Visual BasicDim SomeObj AsNewObject' ... ... ... ...  SomeObj is assigned some value during processing. ' ... ... ... ...  Now we want to find out the data type of SomeObj. Dim Dtype AsInteger      ' To hold numeric data type result. 
Dtype = Type.GetTypeCode(SomeObj.GetType())

See Also

Concepts

Data Types in Visual Basic

Value Types and Reference Types

Programming Element Support Changes Summary

Reference

Object Data Type

System

Object

Type

VarType Function (Visual Basic)

VariantType Enumeration