Constructing Classes in Visual Basic
For constructing classes in Visual Basic we need to first identify the data and member functions of the class structure and then declare decided variables and functions in class. Like in following example we have decided to make a blueprint of a car as sample.
Public Class Car Private name As String Private price As Decimal Private gears As Integer End Class
So here we have defined class as a collection of three main objects which are name, price and gears.
There are some access specifiers that decides how a class variables and member functions are accessed to different components of the program. They are :
|Public||Can be accessed by any class|
|Private||Can be accessed only by members inside the current class|
|Friend||Can be accessed by members in any of the classes in the current assembly (the compiled code file)|
|Protected||Can be accessed by methods in the current class or in any class that inherits from this class|
|Protected Friend||Can be accessed by members in the current application (as with Friend) and by the members in any class that inherits from this class (as with Protected).|