< Previous lesson | Table of Content | Content of this Chapter | Next lesson >

What is Object in Visual Basic?

An object in Visual Basic is a combination of code procedure and data that can be treated as a unit. We call the code procedure as Method and the data as Property .

Up to now you have learned about function and sub procedure , and you also have learned about data type, including user data type . For many problems, you want to combine the procedures (function and sub) with several different data type into a single unit. This combination is called Object. Thus, Object = Methods + Properties in a single unit. The methods or procedure represent the action (verb) that the object does, while the properties or data represent the state or behavior (noun or adjective) of the object.

To define an object, you need to design the Class of that object. Class is the category of the object. For example, City is one class or category of objects. Tokyo is an object derived from City object. City as object may have different data type such as Name, Number of population, and Diameter at certain Year and so on. Those data type we called Properties of the city. Suppose you want to simulate the city growth for example, the Methods for the city may be Growth, Decline and so on.

Another example, Car is a class or category of many different cars object. Now, your-car is an object, derived from Car class. Suppose you want to simulate the behavior of a car, then your car may have several properties such as Gasoline level, Speed, etc. The car may also have several methods such as Brake, Accelerate, Turn-Right, Turn-Left and so on.

< Previous lesson | Table of Content | Content of this Chapter | Next lesson >