Public class members
Outside a class's scope, you can access only its Public members. You use dot notation to refer to Public class members.
In this example, you can access the member variables balance@ and custName$ in the Customer class.
Class Customer
Public custName As String
Public balance As Currency
Sub CheckOverdue
If balance@ > 0 Then
Print "Overdue balance" ' Send an overdue letter.
End If
End Sub
End Class
Dim X As New Customer
Dim newBal As Currency
' This is a legal statement, because custName is Public.
X.custName$ = "Acme Corporation"
X.balance@ = 14.92 ' Balance@ is Public.
' Assigns the value of the Public member variable balance
' to the variable newBal@.
newBal@ = X.balance@
Print X.balance@; newBal@ ' Prints 14.92 14.92
To check for an overdue balance, you can call the Public sub CheckOverdue as in the following example:
Dim Y As Customer
Set Y = X
Y.CheckOverdue 'Prints "Overdue balance"
Print Y.balance@; X.balance@ ' Prints 14.92 14.92