Summary

In this hour we reexamined the concepts behind objects and classes. To use an object, it first must be created. This is accomplished using the VB.NET New keyword and a constructor. As we saw, a constructor is a function that has the same name as the class and returns an instance of the class. For example, to create an instance of the OleDbCommand class, we could use

Dim myCommand as OleDbCommand
myCommand = New OleDbCommand()

Once an object has been created, we can set its properties or call its methods. An object's property can be accessed by listing the object's name, followed by a period, followed by the property name. For example, to access the CommandText property of the myCommand object, we would use the following syntax:

 myCommand.CommandText ...

Get SAMS Teach Yourself ASP.NET in 24 Hours now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.