Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Visual Basic has "Rate()" function, How hard code in VFP6? 1

Status
Not open for further replies.

SMCmtg

Programmer
Mar 27, 2000
90
US
I am programming for &quot;APR&quot; annual percentage rate in a mortgage project. . .VB Foxpro 6 has no function like Rate() in Visual Basic or =Rate() in Excel. . .any guidance on an easy way to calculate this? <br>
THX for any suggestions you might share. . .
 
Have You looked at these 3 commands?<br>
<br>
Payment()<br>
PV()<br>
FV()<br>
<p>David W. Grewe<br><a href=mailto:Dave@internationalbid.net>Dave@internationalbid.net</a><br><a href= > </a><br>
 
The following is from the Excel help:<br><i>Returns the interest rate per period of an annuity. RATE is calculated by iteration and can have zero or more solutions. If the successive results of RATE do not converge to within 0.0000001 after 20 iterations, RATE returns the #NUM! error value.</i><br><br>It sounds like Excel uses brute-force (iteration) to derive the answer.&nbsp;&nbsp;It appears any VFP routine will have to use the same method.&nbsp;&nbsp;I know this is not a great help, but maybe one more financially savvy than I can map out (at least in pseudo-code) what the function needs to do.
 
We are building Rate()function in Visual Basic FoxPro6, which does not have rate() function. . .Term=360 <br>months,Payment=$665.30 month level, Note Rate= 7%<br>Loan Costs=$3000, PV=$97k, FV=$0,&quot;answer from excel @rate&quot;,APR=7.305% Visual Basic=APR=(RATE(360,-665.30,97000,0,.1)*12)*100 &&excel uses iteration. . .brute force. The algebric formula we trying to use is: (FV/PV)raised to the 1/term minus 1. .((0/97000)^1/360)-1<br>Looking to factor to get rid of the fractional exponent.<br>Any recommendations on how to build this in &quot;hard code&quot;?<br>or do we have to go around the barn from a different way?<br>Thank you in advance for any directions. . .<br>Bill
 
I'm not sure exactly what you need but the following is a short procedure or method that will calculate monthly payments.<br><br>Procedure Payment <br>Paramters Principal,Rate,NumOfMonths<br>set decimal to 2<br><br>*Auto loan of 13,500.00 to be paid back in 48 monthly payments<br>*at a rate of 7.5 percent. <br>*What will the monthly payment be?<br>*The number 12 in the formula designates [Months in a year]<br>*Then with the parameters passed with following values:<br><br>*Principal = 13500.00 <br>*Rate = 0.075<br>*NumOfMonths = 48 <br><br>MonthlyPayment = ((Principal*(Rate/12))* ((1+(Rate/12))^48)) / (((1+(Rate/12))^48)-1)<br><br><br><br>*MonthlyPayment = 326.42.<br><br>Return MonthlyPayment <br><br>***********************<br><br>Hope this helps<br>Blackie<br>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top