O'Reilly logo

Microsoft® Visual Basic® 2010 Developer’s Handbook by Klaus Löffelmann and Sarika Calla Purohit

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

Instantiating Classes with New

To create an object that is an instance of a class, you use the keyword New. Internally, the .NET Framework automatically appropriates sufficient memory for storing the field values[10]. An object variable declared with the same type as the class is used to access elements of the class instance. So for example, you create an object of the Contact class by using the following statements:

Dim adr As Contact
adr = New Contact

The first line of code creates an object variable of type Contact, and the second assigns a new instance. You can also combine both lines into one, as demonstrated in the following:

Dim adr As New Contact

Then you can use the class instance with the help of the defined object variables to access the ...

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