Accessing Members

Unless you declare shared objects, you need to instantiate classes and structures before you can use members and store information within those objects. You instantiate a class declaring a variable and using the New keyword as in the following line of code:

Dim testPerson As New Person

Then you can set properties for the new instance or eventually invoke other members such as methods. For example, you could initialize testPerson’s properties as follows:

testPerson.FirstName = "Alessandro" testPerson.LastName = "Del Sole"

Basically when you need to invoke a member of a class, you type the name of the instance (in this example testPerson) followed by a dot and by the name of the member. For shared members, you just write the name ...

Get Visual Basic® 2010 Unleashed 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.