The SimpleLoan Class : Class « Data Type Functions « VBA / Excel / Access / Word






The SimpleLoan Class

 
Option Explicit 
' Loan Properties 
Public PrincipalAmount As Variant 
Public InterestRate As Variant 
Public LoanNumber As Variant 
Public Term As Variant 

Private Sub Class_Initialize() 
    PrincipalAmount = 0 
    InterestRate = 0.08 
    LoanNumber = 0 
    Term = 36 
End Sub 

Public Property Get Payment() As Variant 
    Payment = Application.WorksheetFunction.Pmt _ 
        (InterestRate / 12, Term, -PrincipalAmount) 
End Property 


Sub TestSimpleLoan() 
    Dim objLoan1 As New SimpleLoan 
    Dim objLoan2 As SimpleLoan 
    Set objLoan2 = New SimpleLoan 
    objLoan1.LoanNumber = 1 
    objLoan2.LoanNumber = 2 
    Debug.Print "objLoan1.LoanNumber is: " & objLoan1.LoanNumber 
    Debug.Print "objLoan2.LoanNumber is: " & objLoan2.LoanNumber 
    Set objLoan1 = Nothing 
    Set objLoan2 = Nothing 
End Sub 

 








Related examples in the same category

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