Carthalion Member Licensed User Longtime User Sep 27, 2016 #1 Is there a Pmt function that can be used to calculate a monthly payment?
DonManfred Expert Licensed User Longtime User Sep 27, 2016 #2 What exaactly do you want to calculate? Upvote 0
Erel B4X founder Staff member Licensed User Longtime User Sep 27, 2016 #3 This code is equivalent to Excel pmt function: Code: Copy 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
This code is equivalent to Excel pmt function: Code: Copy 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.
Carthalion Member Licensed User Longtime User Sep 27, 2016 #4 DonManfred said: What exaactly do you want to calculate? Click to expand... I am trying to calculate a mortgage payment. If this was in .Net, the code would be Pi = Pmt(IntRate / 12, Term, -LoanAmt, 0, 0). I do not know what library to load for the Pmt function. Upvote 0
DonManfred said: What exaactly do you want to calculate? Click to expand... I am trying to calculate a mortgage payment. If this was in .Net, the code would be Pi = Pmt(IntRate / 12, Term, -LoanAmt, 0, 0). I do not know what library to load for the Pmt function.
Carthalion Member Licensed User Longtime User Sep 27, 2016 #5 Erel said: This code is equivalent to Excel pmt function: Code: Copy 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. Click to expand... Upvote 0
Erel said: This code is equivalent to Excel pmt function: Code: Copy 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. Click to expand...
DonManfred Expert Licensed User Longtime User Sep 27, 2016 #6 Carthalion said: I do not know what library to load for the Pmt function. Click to expand... 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 ;-) Upvote 0
Carthalion said: I do not know what library to load for the Pmt function. Click to expand... 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 ;-)
Carthalion Member Licensed User Longtime User Sep 27, 2016 #7 DonManfred said: 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 ;-) Click to expand... 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
DonManfred said: 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 ;-) Click to expand... 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?
Carthalion Member Licensed User Longtime User Sep 28, 2016 #8 Carthalion said: Please disregard. You were right. The function works perfectly. I was the problem. This is a great program and I am just getting started with it. Thank you! Click to expand... Upvote 0
Carthalion said: Please disregard. You were right. The function works perfectly. I was the problem. This is a great program and I am just getting started with it. Thank you! Click to expand...