This chapter is from the book

In Hour 1, "Jumping In with Both Feet: A Visual Basic .NET Programming
Tour," you were introduced to programming in Visual Basic .NET by building
a Picture Viewer project. You spent the previous hour digging into the
integrated development environment (IDE) and learning skills critical to your
success with Visual Basic .NET. In this hour, you're going to start
learning about some important programming concepts, namely objects.

The term object as it relates to programming might have been new to
you prior to this book. The more you work with Visual Basic .NET, the more
you'll hear about objects. Visual Basic .NET, unlike its predecessors, is a
true object-oriented language. This hour isn't going to discuss
object-oriented programming in any detailobject-oriented programming is a
very complex subject and well beyond the scope of this book. Instead,
you'll learn about objects in a more general sense.

Everything you use in Visual Basic .NET is an object, so understanding this
material is critical to your success with Visual Basic .NET. For example, forms
are objects, as are the controls you place on a form; pretty much every element
of a Visual Basic .NET project is an object and belongs to a collection of
objects. All objects have attributes (called properties), most have
methods, and many have events. Whether creating simple applications or building
large-scale enterprise solutions, you must understand what an object is and how
it works. In this hour, you'll learn what makes an object an object, and
you'll also learn about collections.

The highlights of this hour include the following:

Understanding objects

Getting and setting properties

Triggering methods

Understanding method dynamism

Writing object-based code

Understanding collections

Using the Object Browser

NOTE

If you've listened to the programming press at all, you've probably
heard the term object oriented, and perhaps words such as
polymorphism, encapsulation, and inheritance. In truth,
these new object-oriented features of Visual Basic are very exciting, but
they're far beyond Hour 3 (or Hour 24, for that matter). You'll learn
a little about object-oriented programming in this book, but if you're
really interested in taking your programming skills to the next level, you
should buy a book dedicated to the subject after you've completed this
one.

Understanding Objects

Object-oriented programming has been a technical buzzword for quite some
time, but as far as Visual Basic programmers are concerned, it became a reality
only with Visual Basic .NET (no previous version of Visual Basic was a true OO
language). Almost everywhere you lookthe Web, publications, booksyou
read about objects. What exactly is an object? Strictly speaking, an
object is a programming structure that encapsulates data and
functionality as a single unit and for which the only public access is through
the programming structure's interfaces (properties, methods, and events).
In reality, the answer to this question can be somewhat ambiguous because there
are so many types of objectsand the number grows almost daily. However,
all objects share specific characteristics, such as properties and methods.

The most commonly used objects in Visual Basic .NET are the form object and
the control object. Earlier hours introduced you to working with forms and
controls and even showed you how to set form and control properties. In your
Picture Viewer project from Hour 1, for instance, you added a picture box and
two buttons to a form. Both the PictureBox and the Button controls are
control objects, but each is a specific type of control object. Another,
less-technical example uses pets. Dogs and cats are definitely different
entities (objects), but they both fit into the category of Pet objects.
Similarly, text boxes and buttons are each a unique type of object, but
they're both considered a control object. This small distinction is
important.