類別可包含各種變數,這些變數類型可以是 dim、private 或 public。
我們只能使用類別的 Get Property 來存取類別之外的這些變數。
您必須明確提及變數類型。
範例:
Class Main_Class
Private var1
Private Sub Class_Initialize
var1 = "BSL"
End Sub
Public Property Get Var
Var = var1
End Property
End Class
' Instantiation of the Class and accessing the variable using Get property
Set oMain = new Main_Class
oMain.Var