Class Properties and Methods
A class can contain properties and methods.
Property Let allows the end user to assign a value to a private class variable.
Property Get is a read-only property and used to retrieve a private class variable.
Methods allow the class to perform the operation that the user wants. The Methods are nothing but Functions or Subroutines.
Example:
In the example below, we are using Properties and Methods to wrap private variables.
Class Comp
Private modStrType
Public Property Let ComputerType(strType)
modStrType = strType
End Property
Public Property Get ComputerType
ComputerType = modStrType
End Property
Public Function Funct1
'Add business logic using class variables
End Function
Public Sub Sub1
'Add business logic using class variables
End Sub
End Class
Set objComp = new Comp
objComp.ComputerType = "Mac" 'Let Property
str1 = objComp.ComputerType 'Get Property. Here, the value of str1 is Mac
objComp.Funct1
objComp.Sub1