Creating Custom Objects : Class « Data Type Functions « VBA / Excel / Access / Word






Creating Custom Objects

 

Option Explicit
Private m_LastName As String
Private m_FirstName As String
Private m_Salary As Currency
Private m_Id As String
Property Get Id() As String
    Id = m_Id
End Property

Property Get LastName() As String
    LastName = m_LastName
End Property

Property Get FirstName() As String
    FirstName = m_FirstName
End Property

Property Get Salary() As Currency
    Salary = m_Salary
End Property
Property Let Id(ref As String)
    m_Id = ref
End Property

Property Let LastName(L As String)
    m_LastName = L
End Property

Property Let FirstName(F As String)
    m_FirstName = F
End Property

Property Let Salary(ByVal dollar As Currency)
    m_Salary = dollar
End Property

Public Function CalcNewSalary(choice As Integer, curSalary As Currency, _
    amount As Long) As Currency
    Select Case choice
        Case 1 ' by percent
            CalcNewSalary = curSalary + ((curSalary * amount) / 100)
        Case 2 ' by amount
            CalcNewSalary = curSalary + amount
    End Select
End Function

 








Related examples in the same category

1.Creating and Using a Class Module
2.Class Module: FileInformation
3.Class Module: FullName
4.The SimpleLoan Class
5.Loan Object Implementation Details
6.Rectangle class
7.Creating the MyRectangle Class
8.Abstraction