O'Reilly logo

VB.NET Language in a Nutshell, Second Edition by Steven Roman PhD, Paul Lomax, Ron Petrusha

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Changes to Programming Elements

VB.NET has removed support for several programming elements because the underlying .NET Framework Class Library and the Common Language Runtime (CLR) contain equivalent functionality. Here are the victims and their replacements. (We discuss the class library and CLR in Chapter 4 and Chapter 5.)

Constants

The Microsoft.VisualBasic.Constants class in the Base Class Library defines a number of constants, such as the familiar vbCrLf constant, so these can be used as always. However, some constants, such as the color constants vbRed and vbBlue, are no longer directly supported. Indeed, the color constants are part of the System.Drawing namespace’s Color structure, so they are accessed as follows:

Me.BackColor = System.Drawing.Color.BlanchedAlmond

In most cases, to access a particular constant that is not a field in the Microsoft. VisualBasic.Constants class, you must designate the enumeration (or structure) to which it belongs, along with the constant name. For example, the vbYes constant in VB 6 continues to exist as an intrinsic constant in VB.NET. However, it has a counterpart in the MsgBoxResult enumeration, which can be accessed as follows:

If MsgBoxResult.Yes = MsgBox("OK to proceed?", ...

For a list of all built-in constants and enums, see Appendix D.

String Functions

The String function has been removed from the language. In its place, we simply declare a string and initialize it, using syntax such as:

Dim str As New String("A"c, 5)

which will define ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required