Hi,

My project has one goal: find interest rate, when loan,period
And payment are given.
Not knowing how to do this, I found,in the net, a function that calculates it.
But unfortunateley,I’m not yet familiar with functions and,therefore,
I don’t know how to implement it in this simple project
Please help.




Public Class Form1

Private Sub btnCalc_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCalc.Click
Dim loan As Double = "175 000.00"
Dim periods As Integer = "60" 'months'
Dim interestRate As Double 'value to retrieve'
Dim payment As Double = "3 941.59"


Double.TryParse(txtLoan.Text, loan)
Integer.TryParse(txtPeriods.Text, periods)
Double.TryParse(txtRate.Text, interestRate)
Double.TryParse(txtPayment.Text, payment)

End Sub


‘BELOW THE FUNCTION THAT RETRIVES INTEREST RATE.
‘I FOUND IT IN THIS LINK:
http://www.planet-source-code.com/vb...2422&lngWId=10

Function ApproxRate(ByVal Periods As Double, ByVal Payment As Double, ByVal loan As Double) As Double


Dim y As Double = 0
Dim n As Double = Periods
Dim z As Double = Payment / loan
Dim x As Double = 1.1
While (Math.Floor((y - 1) * 10000) <> Math.Floor((x - 1) * 10000))
y = x
x = y - ((Math.Pow(y, n + 1) - (Math.Pow(y, n) * (z + 1)) + z) / (((n + 1) * Math.Pow(y, n)) - (n * (z + 1) * Math.Pow(y, n - 1))))
End While
Return CDbl(x - 1)
End Function