Replace Variant with Object


Visual Basic .NET Unleashed
By Paul Kimmel
Table of Contents
Appendix A.  VB6 Programming Element Changes in VB .NET

Replace Variant with Object

The Variant type was implemented in VB6 to support COM. Variant types have been replaced with Object types in Visual Basic .NET. Where you would have used a Variant in VB6, use an Object in Visual Basic .NET.


When you type the word Variant as a data type, Visual Studio .NETthe code editor replaces it with the Object type.

There are several other noteworthy facts regarding Variant types. The Variant keyword still exists in Visual Basic .NET, but it is a do-nothing reserved word that has no meaning. And, finally, in VB6, if you performed arithmetic that resulted in a number too big for a data typefor instance, adding two integers whose sum was greater than the maximum value for integersVB6 converted the result to a Variant. This situation is referred to as overflow. Visual Basic .NET indicates that an overflow condition exists in the task list and refers you to the help documentation indicating the acceptable values for specific data types.


Visual BasicR. NET Unleashed
Visual BasicR. NET Unleashed
Year: 2001
Pages: 222 © 2008-2017.
If you may any questions please contact us: