Pick up just about any "Introduction to Programming" book written in the last twenty years and one of the first few chapters will introduce what are usually called, "control structures" -- "Do loops," "If-Then-Else blocks," and "Case statements" are typical examples. We'll discuss these too, but programming has changed and those things are no longer the most fundamental and important part of programming. The most fundamental concept these days is usually called Object Oriented Programming, or OOP. It is absolutely essential that you understand these concepts to be a successful Visual Basic programmer.
The Word VBA Macro Reconsidered
Here's the complete program that was created by the VBA Macro Recorder:
Sub AboutVB1()
'
' AboutVB1 Macro
' Macro recorded 12/7/1941 by Dan Mabbutt
'
Selection.TypeText Text:="Hello World!"
End Sub
The single program statement consists of:
An object: Selection
A method: TypeText
And a property: Text
In words, this statement says, "Use the TypeText method in the Selection object to add the character string "Hello World!" in the Text property to the current document.
Much of programming these days consists of finding objects that have methods and properties that you need to do whatever you want the program to do. We'll see more of these in programming examples later in this course. One of the real advantages of using the Macro Recorder is that it will suggest the right methods and properties for you to use so you don't have to remember them. Often, you can just change a program that has been recorded to do something slightly different to create exactly the program you want.
Although our "Hello World" program is an introduction to OOP, let's consider it in greater detail in the next section:
2 - The Nature of OOP