This documentation is archived and is not being maintained.

Programming with Objects: Using Classes

Visual Studio 2008

As you learned in an earlier lesson, Visual Basic programs are built with objects such as forms and controls. Objects can also represent real-world things such as a person, a computer, or even something more abstract such as a bank account.

A class is just a representation of a type of object; think of it as the object's blueprint. Just as a single blueprint can be used to build multiple buildings, a class can be used to create multiple copies of an object.

In the following lessons, you will learn how to use classes in your Visual Basic programs.

What Is a Class?

Explains how to use classes to represent objects in your programs.

Modeling a Real-World Object: Creating Your First Class

Describes how to create a class by using a Class Library project.

Adding Properties to a Class

Describes how to add properties to a class and explains fields, property procedures, and property modifiers.

Adding Methods to a Class

Explains how to add methods to a class so that it can perform actions.

Adding Events to a Class

Shows how to add events to classes so that you can write code to handle the events.

Testing a Class

Shows how to create an instance of a class in order to test it.

Building a Class from an Existing Class: Using Inheritance

Describes how to use inheritance to create a class that is based on an existing class.

Using Collections to Manage Multiple Objects

Explains how to use a collection to store and retrieve groups of like objects.

Closer Look: Creating Multiple Versions of the Same Method with Overloading

Demonstrates how to add multiple versions of a method to your class.

Closer Look: Overriding Members

Explains how to override a member of a derived class.

Closer Look: Using a For Each...Next Loop in a Collection

Explains how to use a For Each...Next loop to loop through a collection.

Closer Look: Handling Events

Shows how to raise an event, create an event handler, and write code to handle events.

Visual Basic Guided Tour

The Visual Basic Guided Tour is a series of sequential lessons that introduce you to the basics of programming in Visual Basic.