クラスには、プロパティとメソッドを含めることができます。
Property Letを使用すると、エンド・ユーザーはプライベート・クラス変数に値を割り当てることができます。
Property Getは読取り専用プロパティであり、プライベート・クラス変数の取得に使用されます。
メソッドを使用すると、クラスでユーザーが希望する操作を実行できます。メソッドは単なる関数またはサブルーチンです。
例:
次の例では、プロパティとメソッドを使用してプライベート変数をラップしています。
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