Share via


Data Type Changes for Visual Basic 6.0 Users

Visual Basic 2008 updates data types for interoperability with other programming languages and the common language runtime. The changes affect data type declaration, usage, and conversion.

Visual Basic 6.0

In Visual Basic 6.0, you use the Deftype statements — DefBool, DefByte, DefCur, DefDate, DefDbl, DefDec, DefInt, DefLng, DefObj, DefSng, DefStr, and DefVar — to set a variable's default type.

Use the Currency data type for calculations involving money and for fixed-point calculations.

A Date is stored in a Double format using eight bytes.

If two Variant variables containing integers are multiplied, an overflow condition causes the data type of the result to be changed to Double.

Use the LSet and RSet statements to copy a variable of one user-defined type to another variable of a different user-defined type.

Visual Basic 2008

The Deftype statements are not supported in Visual Basic 2008. The Currency data type also is not supported. Instead, use the new Decimal data type, which can handle more digits on both sides of the decimal point, for all money variables and calculations. Decimal is also directly supported by the common language runtime.

In Visual Basic 2008, the Date data type uses the common language runtime DateTime data type, which is an eight-byte integer value. Because of these different representations, there is no implicit conversion between the Date and Double data types. To convert between Double and the Visual Basic 6.0 representation of Date, use the ToOADate and FromOADate methods of the DateTime structure in the System namespace.

If multiplication of two Object variables containing integers results in an overflow, the result is changed to the 64-bit Long data type.

You cannot use LSet and RSet to assign one data type to another. Doing this requires a type-unsafe operation, particularly with structures, which could result in unverifiable code.

See Also

Concepts

Programming Element Support Changes Summary

Reference

Decimal Data Type (Visual Basic)

Date Data Type (Visual Basic)

DateTime

TimeSpan

Val Function

Type Conversion Functions

Data Type Summary (Visual Basic)

Double Data Type (Visual Basic)

Long Data Type (Visual Basic)