Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.
Function InterestCollected(Original As Double, TotalMonths As Double, Payment1 As Double, Months1 As Double, Rate1 As Double, Months2 As Double, Rate2 As Double)
Dim Interest As Double
Dim NewBal As Double
Dim Balpaydown As Double
Dim Bal As Double
Dim PreviousInt As Double
Dim i As Integer
Bal = Original
NewBal = Original
PreviousInt = 0
For i = 1 To Months1
Interest = NewBal * (Rate1 / 12)
Balpaydown = Payment1 - Interest
Bal = NewBal
NewBal = Bal - Balpaydown
SumofInt = Interest + PreviousInt
PreviousInt = SumofInt
Next i
If Months2 = 0 Then InterestCollected = SumofInt Else
Payment2 = Pmt(Rate2, TotalMonths - Months1, NewBal)
For i = 1 To Months2
Interest = NewBal * (Rate2 / 12)
Balpaydown = Payment2 - Interest
Bal = NewBal
NewBal = Bal - Balpaydown
SumofInt = Interest + PreviousInt
PreviousInt = SumofInt
Next i
If Months3 = 0 Then InterestCollected = SumofInt Else
Payment3 = Pmt(Rate3, TotalMonths - Months1, NewBal)
For i = 1 To Months3
Interest = NewBal * (Rate3 / 12)
Balpaydown = Payment3 - Interest
Bal = NewBal
NewBal = Bal - Balpaydown
SumofInt = Interest + PreviousInt
PreviousInt = SumofInt
Next i
If Months4 = 0 Then InterestCollected = SumofInt Else
Payment4 = Pmt(Rate4, TotalMonths - Months1, NewBal)
For i = 1 To Months4
Interest = NewBal * (Rate4 / 12)
Balpaydown = Payment4 - Interest
Bal = NewBal
NewBal = Bal - Balpaydown
SumofInt = Interest + PreviousInt
PreviousInt = SumofInt
Next i
If Months4 = 0 Then InterestCollected = SumofInt Else
Payment5 = Pmt(Rate5, TotalMonths - Months1, NewBal)
For i = 1 To Months5
Interest = NewBal * (Rate5 / 12)
Balpaydown = Payment5 - Interest
Bal = NewBal
NewBal = Bal - Balpaydown
SumofInt = Interest + PreviousInt
PreviousInt = SumofInt
Next i
InterestCollected = PreviousInt
End If
End If
End If
End If
End Function
IF [...] THEN [...]
IF [...] THEN [...] ELSE [...]
IF [...] THEN [...] ELSE IF [...] THEN [...]
IF [...] THEN
[...]
END IF
IF [...] THEN
[...]
ELSE
[...]
END IF
IF [...] THEN
[...]
ELSE IF [...] THEN
[...]
ELSE
[...]
END IF
[...]
For i = 1 To Months1
Interest = NewBal * (Rate1 / 12)
Balpaydown = Payment1 - Interest
Bal = NewBal
NewBal = Bal - Balpaydown
SumofInt = Interest + PreviousInt
PreviousInt = SumofInt
Next i
If Months2 = 0 Then
InterestCollected = SumofInt
Exit Sub
Else
Payment2 = Pmt(Rate2, TotalMonths - Months1, NewBal)
For i = 1 To Months2
Interest = NewBal * (Rate2 / 12)
Balpaydown = Payment2 - Interest
Bal = NewBal
NewBal = Bal - Balpaydown
SumofInt = Interest + PreviousInt
PreviousInt = SumofInt
Next i
End If
If Months3 = 0 Then
InterestCollected = SumofInt
Exit Sub
Else
[...]
Function InterestCollected(Original As Double, TotalMonths As Double, Payment1 As Double, Months1 As Double, Rate1 As Double, Months2 As Double, Rate2 As Double)
Dim Interest As Double
Dim NewBal As Double
Dim Balpaydown As Double
Dim Bal As Double
Dim PreviousInt As Double
Dim i As Integer
Bal = Original
NewBal = Original
PreviousInt = 0
For i = 1 To Months1
Interest = NewBal * (Rate1 / 12)
Balpaydown = Payment1 - Interest
Bal = NewBal
NewBal = Bal - Balpaydown
SumofInt = Interest + PreviousInt
PreviousInt = SumofInt
Next i
If Months2 = 0 Then
InterestCollected = SumofInt
Else
Payment2 = Pmt(Rate2, TotalMonths - Months1, NewBal)
For i = 1 To Months2
Interest = NewBal * (Rate2 / 12)
Balpaydown = Payment2 - Interest
Bal = NewBal
NewBal = Bal - Balpaydown
SumofInt = Interest + PreviousInt
PreviousInt = SumofInt
Next i
If Months3 = 0 Then
InterestCollected = SumofInt
Else
Payment3 = Pmt(Rate3, TotalMonths - Months1, NewBal)
For i = 1 To Months3
Interest = NewBal * (Rate3 / 12)
Balpaydown = Payment3 - Interest
Bal = NewBal
NewBal = Bal - Balpaydown
SumofInt = Interest + PreviousInt
PreviousInt = SumofInt
Next i
If Months4 = 0 Then
InterestCollected = SumofInt
Else
Payment4 = Pmt(Rate4, TotalMonths - Months1, NewBal)
For i = 1 To Months4
Interest = NewBal * (Rate4 / 12)
Balpaydown = Payment4 - Interest
Bal = NewBal
NewBal = Bal - Balpaydown
SumofInt = Interest + PreviousInt
PreviousInt = SumofInt
Next i
If Months4 = 0 Then
InterestCollected = SumofInt
Else
Payment5 = Pmt(Rate5, TotalMonths - Months1, NewBal)
For i = 1 To Months5
Interest = NewBal * (Rate5 / 12)
Balpaydown = Payment5 - Interest
Bal = NewBal
NewBal = Bal - Balpaydown
SumofInt = Interest + PreviousInt
PreviousInt = SumofInt
Next i
InterestCollected = PreviousInt
End If
End If
End If
End If
End Function
InterestCollected = SumofInt
Else
Payment2 = Pmt(Rate2, TotalMonths - Months1, NewBal)
end if