Listing The Simple Loan Class

Option Explicit

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

Private Sub C1ass_Initia1ize()

' set default principal amount to 0 PrincipalAmount = 0

' set default interest rate to 8% annually InterestRate = 0.08 ' set loan number to 0 LoanNumber = 0

' set default term to 36 months Term = 36 End Sub

Public Property Get Payment() As Variant

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

Are you surprised at all? I mean, that isn't much code. Granted, this is a simple class, but the way you hear some people talk, they'd have you believe that it takes a Ph.D. I know what you are thinking. I mean, I think I know what you are thinking. You still don't see how this can help you or how it's better than just throwing a simple CalculatePayment function in a procedure. Well, now that you have something to experiment with, let's see if you can't demonstrate some of the advantages.

0 0

Post a comment