Un evento Class può contenere proprietà e metodi.
Il metodo Property Let consente all'utente finale di assegnare un valore a una variabile di classe privata.
Il metodo Property Get è una proprietà di sola lettura utilizzata per recuperare una variabile di classe privata.
I metodi consentono alla classe di eseguire l'operazione desiderata dall'utente. I metodi non sono altro che funzioni o subroutine.
Esempio
Nell'esempio seguente vengono utilizzati proprietà e metodi per racchiudere le variabili private.
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