1. Tech

Your suggestion is on its way!

An email with a link to:

http://visualbasic.about.com/od/learnvba/l/blecvbai0202.htm

was emailed to:

Thanks for sharing About.com with others!

VB Programming for the Non-Programmers!
2 - The Nature of OOP
Lesson 2
Objects!

1 - The Word VBA Macro Reconsidered

2 - The Nature of OOP

3 - So What Are Methods and Properties?

4 - The Word Object Model

5 - Objects in General


What is an "object"?

Here are some definitions of "object" provided by other sources:

"An object is a self-contained entity that consists of both data and procedures to manipulate the data."
(www.webopedia.com)

"A data structure (abstract data type) encapsulated with a set of routines, called methods, which operate on the data. Operations on the data can only be performed via these methods, which are common to all objects that are instances of a particular class."
(www.hyperdictionary.com)

"An object is something that has an identity, a state, and a behaviour. The state is encoded in instance variables (data members), the behaviour is encoded in methods (member functions)."
(www.wikipedia.org)

Definitions like these give OOP the reputation of being really difficult! Here's one that is much less precise, but maybe easier to wrap your mind around:

An object is just a program that already exists and is programmed in a way that lets you use it as part of your program.

Usually, this program was written by somebody else, such as a programmer at Microsoft, but when you learn more about programming, you can write your own objects.

Some examples of objects:

Microsoft Word
Selection . . (used in the Word VBA Macro we have been writing)
Range . . (also often used in Word VBA Macros)

One key thing to understand about objects is that objects are usually inside other objects. For example, both Selection and Range are objects in Microsoft Word.

You might be asking, "Why don't we just call these things 'programs'? Why do we have to use a confusing word like 'objects'?" The answer is that most programs are not objects. Objects are programs that are written so they have an interface (there's another software term!) that lets other programs use their methods and properties.

Selection is an object. Part of the Microsoft Word program contains information about the part of the current Word document that has been 'selected'. If you are looking at a Word document, the Text property of the Selection object will be highlighted. But even if no text is selected in a Word document, the code for the Selection object still exists in Word and we can still use the methods and properties.

Notice that we used the words method and property in this explanation. This is a good place to consider the next subject:

3 - So What Are Methods and Properties?

©2014 About.com. All rights reserved.