Learn Access 2003 VBA with The Smart Method
60
www.LearnAccessVBA.com
Lesson 3-2: Understand
methods
What are methods.
As well as having properties to describe an object some objects have
certain functionality too. Let’s consider a Car object. We may have
precisely described it by setting properties such as Color, NumberOfSeats
and FuelType but what is the car for. Is it a film prop, a paperweight, or
does it actually do something.
The things objects can do are called methods.
All cars have several methods such as StartEngine, MoveForward, Stop,
SteerLeft and SteerRight. Some cars have methods that are not common
to all cars such as StartAirConditioner or EnableCruiseControl.
Methods may be modified by arguments
Access objects have methods too. For example a Combo Box object has an
AddItem method.
Simply invoking the MoveForward method of the Car object wouldn’t
really be enough. To more precisely tell the car what to do we might
want to say:
Move forward three metres.
In order to do this we’d need to invoke the MoveForward method along
with some instructions telling the car how to move forwards. These
instructions are called parameters or arguments. The actual
MoveForward() method call would more likely be something like this:
MoveForward( 3 )
note
Some programmers prefer the
term Parameter instead of
Argument. Both are correct.
Session3