
Nov 29th, 2012, 04:31 AM
#1
Thread Starter
Lively Member
[RESOLVED] How to Find R in formula??
hi all,
am using DAO in VB6 and MSAccess as back hand.
now, i have a formula, u can find out EMI for Loan with that formula. formula is as below.
EMI = P * R * (1 + R)^N / ((1 + R)^N  1) > Plz Note "R" = R/1200
Now i can find EMI through above formula in vb6.
now i want to find "R" from that.
eg. If P = 100000, N = 36 Months, EMI = 3227, R = ??
its Answer is 10 ( R = 10%)
but how can i calculate through vb6 coding.
plz. HELP me on this if possible.
thanks a lot in advance.
kaushal

Nov 29th, 2012, 05:34 AM
#2
Re: How to Find R in formula??
There is no "nice" formula for R in terms of the remaining variables, however you can numerically compute R pretty easily using a method called "quadrature", where I'm assuming a solution exists somewhere, and the EMI function constantly increases. Hopefully these are reasonable assumptions. The following VB.NET (sorry, I don't have access to VB6 anymore) code gives R=0.008338... on your input, which agrees with the results of a numerical solver. (You said the answer should be R=10%=0.1, but I don't believe you since plugging this in directly doesn't give equality. Maybe you haven't listed some unit conversion somewhere or your numbers aren't right.)
.
VB Code:
Public Class Form1 Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load MessageBox.Show(FindR(3227, 100000, 36)) End Sub Private Function FindR(EMI As Double, P As Double, N As Double) As Double 'Use "quadrature" to find the solution Dim MinR As Double Dim MaxR As Double Dim MidR As Double MinR = 0 MaxR = 1 Do Until Math.Abs(MaxR  MinR) < 0.000001 Dim TestVal As Double MidR = (MaxR + MinR) / 2 TestVal = P * MidR * (1 + MidR) ^ N / ((1 + MidR) ^ N  1) If TestVal < EMI Then MinR = MidR Else MaxR = MidR End If Loop Return MidR End Function End Class
The time you enjoy wasting is not wasted time.
Bertrand Russell
< Remember to rate posts you find helpful.

Dec 1st, 2012, 06:42 AM
#3
Thread Starter
Lively Member
Re: How to Find R in formula??
hi Jemidiah,
thanks a lot for ur reply and help. i solve my problem with ur suggestion.
if u read my question carefully then u find that i clearly mention there that value of "R" in formula is "R" = R / 1200. so here in ur suggestion u find R = 0.008338.
now u just have to multiply it with 1200. eg. R = 0.008338 * 1200 = "10.0056" which i mention in my question.
anyway, thanks a lot for your Help.
kaushal

Dec 1st, 2012, 06:43 PM
#4
Re: [RESOLVED] How to Find R in formula??
Cool, glad it worked out.
While I suppose it doesn't matter, for the unit conversion you had said, "Plz Note "R" = R/1200", which I do not find at all "clear". Given your most recent post, by "R" on the left you actually meant the R which appears in your formula, and by R on the right you meant an R which does not appear in your formula. I thought you were defining a new variable "R" and not using it later, which is not the case. To be honest, this point is stupid and needlessly confusing. You should probably have just ignored the unit conversion entirely since it's irrelevant to the problem.
The time you enjoy wasting is not wasted time.
Bertrand Russell
< Remember to rate posts you find helpful.
Posting Permissions
 You may not post new threads
 You may not post replies
 You may not post attachments
 You may not edit your posts

Forum Rules

Click Here to Expand Forum to Full Width
Survey posted by VBForums.
