Description
The Class statement declares the name of a class, as well as a definition of the variables, properties, and methods that comprise the class.
This statement has the form:
Class name
statements
End Class
Parameter | Description |
---|---|
name | (required) Specifies the name of the Class Note: name must follow the standard variable naming conventions |
statements | (required) Specifies one or more statements that define the variables, properties, and methods of the Class |
Examples
The following example shows the basic use of this statement:
Class Employee
Private m_Name
Private m_Age
Private Sub Class_Initialize
m_Name = ""
m_Age = 103
End Sub
' Name property
Public Property Get Name
Name = m_Name
End Property
Public Property Let Name(name)
m_Name = name
End Property
' Age property (read only)
Public Property Get Age
Age = m_Age
End Property
End Class
Dim c
Set c = New Customer
c.Name = "Peter Weyland"
MsgBox (c.Name)
MsgBox (c.Age)
This produces the following result (each line in a separate pop-up message box):
Peter Weyland
103
Miscellaneous Information
Supported in Version: | 5.0 |
---|