A class is a publicly-owned sub or Function procedure that is declared by a user in a class.
For example: The following code adds a withdrawal method to a account that allows the user to add the public function process to the class module:
Public Function withdrawal (Byval Amount as Currency,_
Byval Transactioncode as Byte) as Double
"(Code to perform t He withdrawal and return the
' new balance,or to raise ' overdraft error.
End Function
If the class account has the balance attribute, the user can also not return the balance value, because the user can easily access the Balance property after the withdrawal function is called, so the user can replace the function with a public process.
Note: If you find that the withdrawal is set to a procedure, after each call to the withdrawal process to access the Balance attribute value, then the withdrawal set to return balance value, will be more efficient. This is because for the properties of a class, the value of getting an attribute at a time is also calling a common function propertyget and accessing some public variables, regardless of whether the PropertyGet function is explicit or implicitly declared.
In the class module, by defining the attributes and methods, it constitutes a class external interface, just as the data encapsulation of the class, if the user declare a process as private, then it can not form part of the interface. This means that users can change the operation of the entire program by changing some of the private internal processes within the class without having to change the code that uses the class.
More importantly, users can also change the functions of the whole program by changing the Sub or Function procedure of the public as the method of the class, without involving the code that uses the class, just as the parameter of the procedure cannot be changed and the return type of the function, and from the outside, the user cannot change the interface of a class.
Hiding the specifics of a class beyond the interface of a class can be considered a manifestation of the encapsulation of a class, which allows the user to improve the performance of one method of a class without changing the code of the class, or to completely alter the function of a class's methods.