建立一個類

Class Car

    Private wheels_
    Private distances_

    ' Property getter
    Public Property Get Wheels()
        Wheels = wheels_
    End Property
    
    ' Property setter
    Public Property Let Wheels(v)
        wheels_ = v
    End Property
    
    ' Parameterless Constructor
    Public Sub Class_Initialize()
        distances_ = Array(0)
    End Sub
    
    ' Method
    Public Function GetTotalDistance()
        dim d
        'GetTotalDistance = 0
        For Each d in distances_
            GetTotalDistance = GetTotalDistance + d
        Next
    End Function
    
    ' Void Method
    Public Sub Drive(distance)
        distances_(ubound(distances_)) = distance
        Redim Preserve distances_(ubound(distances_)+1)
    End Sub
    
End Class