Android Question Pmt function

DonManfred

Expert
Licensed User
Longtime User
What exaactly do you want to calculate?
 
Upvote 0

Carthalion

Member
Licensed User
Longtime User
This code is equivalent to Excel pmt function:

B4X:
Sub pmt (Rate As Double, Nper As Double, Pv As Double) As Double
   If Rate = 0 Then
     Return - Pv / Nper
   Else
     Return Pv * Power(Rate + 1, Nper) * Rate / (1 - Power(Rate + 1, Nper))
   End If
End Sub

It is based on the code from Apache POI library.
 
Upvote 0

Carthalion

Member
Licensed User
Longtime User
See Erels answer. This seems to be the solution for your question. There is no library which does have a pmt function. But all you need is the sub above ;-)

Maybe I did this wrong: I tested using...

Sub pmt (Rate As Double, Nper As Double, Pv As Double) As Double
If Rate = 0 Then
Return - Pv / Nper
Else
Return Pv * Power(Rate + 1, Nper) * Rate / (1 - Power(Rate + 1, Nper))
End If
End Sub

Sub CalcPmt
Dim Pi As Double
Pi = pmt(.07,360, 100000)
lblPi.Text = Pi
End Sub


It gives the answer as 849, but a 100K loan amount with a 30 year payment at 7% is 665. What do you think?
 
Upvote 0
Top