VERSION 1.0 CLASS
BEGIN
MultiUse = -1 'True
Persistable = 0 'NotPersistable
DataBindingBehavior = 0 'vbNone
DataSourceBehavior = 0 'vbNone
MTSTransactionMode = 0 'NotAnMTSObject
END
Attribute VB_Name = "Class1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = True
Attribute VB_PredeclaredId = False
Attribute VB_Exposed = False
Option Explicit
'Loan.cls - This is a class module that provides
'blue print for creating loan objects
'These variables are public properties for loan object
Public principal As Currency
Public annualinterestrate As Single
'These variables are known with in this class module
Private Mo As Integer ' number of monts loan
Private Ba() As Currency 'Amortized balance array
'lets user assign a value to months property
Property Let months(M)
Mo = M
End Property
'gets current value of months property for user
Property Get months()
months = Mo
End Property
'let user assign a value to years property
Property Let years(Y)
'Mo = Y * 12
Mo = Y * 2
End Property
'gets current value of years property for user
Property Get years()
'years = Mo / 12
years = Mo / 2
End Property
'
'gets claculated payment property for user
Property Get payment()
Dim monthlyinterestrate As Single
'verify that all properties are loaded
If principal = 0 Or annualinterestrate = 0 Or Mo = 0 Then
payment = 0
Else
monthlyinterestrate = annualinterestrate / 1200
payment = (-monthlyinterestrate * principal) / _
((monthlyinterestrate + 1) ^ (-Mo) - 1)
End If
End Property
'method to fill amortized balance array
Public Sub amortize()
Dim i
Dim balance As Currency
Dim paid As Currency
ReDim Ba(0)
Ba(0) = principal
paid = CCur(payment / 100) * 100
Do Until Ba(i) <= 0
i = i + 1
ReDim Preserve Ba(i)
Ba(i) = Ba(i - 1) * (1 + annualinterestrate / 1200)
Ba(i) = Ba(i) - paid
Ba(i) = CCur(Ba(i) / 100) * 100
Loop
End Sub
'gets balance of loan after N months for user
Property Get balance(N)
If N > UBound(Ba) Or N < 1 Then
balance = 0
Else
balance = Ba(N)
End If
End Property