Well you are almost right, although you can use Public Variables in a class to expose them as properties it is not recommended. The proper way is to make actual Properties:
VB Code:
'declare private variables to hold internal values
Private m_Name as string
Private m_LoggedIn as boolean
'then expose them through properties
Public Property Let Name(NewValue as string)
m_Name=NewValue
End Property
Public Property Get Name() as string
Name=m_Name
End Property
As for subs you can pass things in as arguments the same way you do for any other subs or you can use the internal variables within the class instead of passing anything in.
VB Code:
Public Sub WhoBarked()
MsgBox m_Name & " barked! " 'references the private variable
End Sub
'using it like this
CurrentUser.Name="Bob"
CurrentUser.WhoBarked 'Would show "Bob Barked"
Another thing with classes is events. You first declare them and then raise them where needed. Of course for the client to use them they will need to delcare your object WithEvents
VB Code:
'in class
Public Event LoggedOff()
Public Sub LogOff() 'of course normal a sub wouldn't really raise an event
'perform log off here
'raise event
RaiseEvent LoggedOff
End Sub
'in app
Private WithEvents CurrentUser as cUser
Private Sub Form_Load()
Set CurrentUser=New cUser
End Sub
Private Sub Form_Unload(Cancel as integer)
Set CurrentUser=Nothing
End Sub
Private Sub CurrentUser_LoggedOff()' there is no need to create this it will show up when the object is declared withevents
Msgbox "Hey you fired an event"
End Sub