If you're an experienced VB6 programmer, you might be tempted to skim through this chapter. However, you should take note of the following significant differences between VB6 and VB.NET:
The Visual Basic .NET equivalent to the VB6 Currency type is the Decimal type. While these two types are for most purposes interchangeable, they differ in terms of precision. The Decimal type is a fixed-precision number with up to 28 digits, plus the position of the decimal point. Decimal values require the suffix "m" or "M".
While in VB6, Char is a single-character String, in Visual Basic .NET Char is a type in its own right.
Microsoft no longer recommends Hungarian[1] notation in public identifiers. Meaningful identifiers should be used (studentAge rather than x01) but no type-identifier prefix is needed or recommended.
[1] Hungarian notation was named to honor its inventor, Charles Simonyi of Microsoft, who was Hungarian. The idea was to prefix identifiers with letters indicating their type. Thus, an integer variable might be named iAge, a long variable might be named lTotal. Some of the prefixes were rather obscure, such as lpszName (with lpsz signifying "long pointer to a string ending in zero"). In any case, Hungarian notation does not lend itself to object-oriented programming (in which there may be thousands of types defined) and so is now deprecated in public identifiers. What you do with private identifiers is entirely up to you.
In VB.NET, enumerations are formal types, and so an explicit conversion is required to convert between an Enum type and an intrinsic type (such as Integer, Boolean, etc.).
In VB6 enumerations are just aliases for integer values. In VB.NET, enumerations are actual types, and you must access enumerated constants using the fully qualified name of the enumeration (e.g., Temperature.FreezingPoint).
In VB.NET, there is no Set statement; however properties have Set and Get accessors, as described in Chapter 5.
Top |