To get a handle on these these two terms, lets consider some phrases from the definitions quoted in the previous section:
- "data and procedures" (used by www.webopedia.com)
- "methods, which operate on the data" (used by www.hyperdictionary.com)
- "a state, and a behaviour" (used by www.wikipedia.org)
If you think about them carefully, you will see that these definitions say almost the same thing, but they use different words to say it. I said that an object is just a program. Let's look at the statement in the Word VBA macro:
Selection.TypeText Text:="Hello World."
Notice that this statement does something and contains information.
What the statement does is called a method. TypeText is the name of that method. The information contained is called a property. Text is the name of the property and "Hello World" is the value of the property.
In fact, the only parts of the statement that are not objects, methods, or properties are the Visual Basic symbols and operators:
' . ' - The 'dot' operator
' := ' - The named parameter symbol
' " ' - The string delimiter symbol
In the past, people have thought of a program as just a logical procedure that takes input data, processes it, and produces output data. They thought that the job of the programmer was to know how to write that programming logic. Object Oriented Programming has created a newer way to think about the job of the programmer. The job is now to understand the objects used to change information rather than all of the individual steps. Most of the steps are usually inside the objects anyway.
But how do you figure out what all these objects, methods and properties are? To understand that, we next consider the 'parent' object of all the objects we have been considering ... the Word object.