By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
428,659 Members | 940 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 428,659 IT Pros & Developers. It's quick & easy.

Financial.Rate Cannot calculate rate using the arguments provided

P: n/a
I'm getting this error when running this program:
Cannot calculate rate using the arguments provided

Module Module1

Sub Main()

Rate(360, -694.44444444444446, 244274.69178082192)
End Sub

End Module

This is a vb console application, has anybody seen this before? how can I
fix this?
Mar 27 '06 #1
Share this Question
Share on Google+
6 Replies


P: n/a
I have never used this function and this probably won't help you much.
But have you looked at the folowing link:
http://msdn.microsoft.com/library/de.../vafctRate.asp

Mar 28 '06 #2

P: n/a

Programador wrote:
I'm getting this error when running this program:
Cannot calculate rate using the arguments provided

Module Module1

Sub Main()

Rate(360, -694.44444444444446, 244274.69178082192)
End Sub

End Module

This is a vb console application, has anybody seen this before? how can I
fix this?


There is an indispensible .NET tool called Reflector (first result on
google for that word), which disassembles the CLR into your choice of
VB.NET or C#. If you ever need to know what the Framework is doing, or
how it does it, it should be your first port of call. This is its
output when asked to examine the Microsoft.VisualBasic.Financial.Rate
function:

Public Shared Function Rate(ByVal NPer As Double, ByVal Pmt As Double,
ByVal PV As Double, ByVal FV As Double = 0, ByVal Due As DueDate = 0,
ByVal Guess As Double = 0.1) As Double
Dim num2 As Double
If (NPer <= 0) Then
Throw New
ArgumentException(Utils.GetResourceString("Rate_NP erMustBeGTZero"))
End If
Dim num1 As Double = Guess
Dim num4 As Double = Financial.LEvalRate(num1, NPer, Pmt, PV, FV,
Due)
If (num4 > 0) Then
num2 = (num1 / 2)
Else
num2 = (num1 * 2)
End If
Dim num5 As Double = Financial.LEvalRate(num2, NPer, Pmt, PV, FV,
Due)
Dim num6 As Integer = 0
Do While True
If (num5 = num4) Then
If (num2 > num1) Then
num1 = (num1 - 1E-05)
Else
num1 = (num1 - -1E-05)
End If
num4 = Financial.LEvalRate(num1, NPer, Pmt, PV, FV,
Due)
If (num5 = num4) Then
Throw New
ArgumentException(Utils.GetResourceString("Financi al_CalcDivByZero"))
End If
End If
num1 = (num2 - (((num2 - num1) * num5) / (num5 - num4)))
num4 = Financial.LEvalRate(num1, NPer, Pmt, PV, FV, Due)
If (Math.Abs(num4) < 1E-07) Then
Return num1
End If
Dim num3 As Double = num4
num4 = num5
num5 = num3
num3 = num1
num1 = num2
num2 = num3
num6 += 1
If (num6 > 39) Then
Throw New
ArgumentException(Utils.GetResourceString("Financi al_CannotCalculateRate"))
End If
Loop
End Function
Now, since I know less than nothing about the purpose of this function,
or the meaning of the arguments, I can't say what is going wrong or
why. It looks like the loop in the second part of the function is
repeatedly run until num4 is very close to zero, and if this doesn't
happen within 40 iterations, the Exception you saw is thrown.
Presumably some kind of iterative solution is taking place, and the
fact that it doesn't converge in 40 iterations is used as a signal that
there is no solution.

At any rate, you should be able at the very least to now step through
this code yourself and work out what is going wrong.

--
Larry Lard
Replies to group please

Mar 28 '06 #3

P: n/a
From the docs:

"Rate is calculated by iteration. Starting with the value of Guess, Rate
cycles through the calculation until the result is accurate to within
0.00001 percent. If Rate cannot find a result after 20 tries, it fails. If
your guess is 10 percent and Rate fails, try a different value for Guess"

Provide a different value for the Guess parameter (default is 0.1).
0.01 seems to be working for those particular parameters

/claes
"Programador" <Pr*********@discussions.microsoft.com> wrote in message
news:13**********************************@microsof t.com...
I'm getting this error when running this program:
Cannot calculate rate using the arguments provided

Module Module1

Sub Main()

Rate(360, -694.44444444444446, 244274.69178082192)
End Sub

End Module

This is a vb console application, has anybody seen this before? how can I
fix this?

Mar 28 '06 #4

P: n/a
Don

How can you have a payment of -694.44444444444446 or a balance of
244274.69178082192? Just curious. As far as I know, US Dollars have to
be paid in increments of .01. At least the mortgage companies I've
worked at for over 20 years have required it that way. I don't think
their servicing software will accept payments down to one trillionith
of a penny anyway.

I can't think of any real world scenario where that would make sense,
and, it will return non-sense results for your Rate calculation.

If you round your figures to the nearest penny your function should
not only work but should also return an accurate rate.

Regards,

Don

On Mon, 27 Mar 2006 14:11:01 -0800, Programador
<Pr*********@discussions.microsoft.com> wrote:
I'm getting this error when running this program:
Cannot calculate rate using the arguments provided

Module Module1

Sub Main()

Rate(360, -694.44444444444446, 244274.69178082192)
End Sub

End Module

This is a vb console application, has anybody seen this before? how can I
fix this?

Mar 29 '06 #5

P: n/a
I have come across several instances where financial calculations use 4
decimal places until the final result is rounded to 2 decimal places.

One example is fuel e.g. 1.8990 per gallon

"Don" <don81846@NO_CaCa.Earthlink.net> wrote in message
news:ch********************************@4ax.com...

How can you have a payment of -694.44444444444446 or a balance of
244274.69178082192? Just curious. As far as I know, US Dollars have to
be paid in increments of .01. At least the mortgage companies I've
worked at for over 20 years have required it that way. I don't think
their servicing software will accept payments down to one trillionith
of a penny anyway.

I can't think of any real world scenario where that would make sense,
and, it will return non-sense results for your Rate calculation.

If you round your figures to the nearest penny your function should
not only work but should also return an accurate rate.

Regards,

Don

On Mon, 27 Mar 2006 14:11:01 -0800, Programador
<Pr*********@discussions.microsoft.com> wrote:
I'm getting this error when running this program:
Cannot calculate rate using the arguments provided

Module Module1

Sub Main()

Rate(360, -694.44444444444446, 244274.69178082192)
End Sub

End Module

This is a vb console application, has anybody seen this before? how can I
fix this?

Mar 30 '06 #6

P: n/a
Don

The mathematical formula for calculating the periodic payment required
to amortize an amount will result in a theoretical payment amount.
E.g. -694.44444444444446 as in the original post.

Using that figure in the Rate calculation will give an equally
theoretical result. Try to give the gas station attendant 9.495 for 5
gallons of gas at 1.899 per gallon.

As I said:

"As far as I know, US Dollars have to be **PAID** in increments of
..01."

My post wasn't meant to be as strident as it may have sounded.

Regards,

Don

On Thu, 30 Mar 2006 05:22:00 -0800, "Jim Hughes"
<NO*********@Hotmail.com> wrote:
I have come across several instances where financial calculations use 4
decimal places until the final result is rounded to 2 decimal places.

One example is fuel e.g. 1.8990 per gallon

"Don" <don81846@NO_CaCa.Earthlink.net> wrote in message
news:ch********************************@4ax.com.. .

How can you have a payment of -694.44444444444446 or a balance of
244274.69178082192? Just curious. As far as I know, US Dollars have to
be paid in increments of .01. At least the mortgage companies I've
worked at for over 20 years have required it that way. I don't think
their servicing software will accept payments down to one trillionith
of a penny anyway.

I can't think of any real world scenario where that would make sense,
and, it will return non-sense results for your Rate calculation.

If you round your figures to the nearest penny your function should
not only work but should also return an accurate rate.

Regards,

Don

On Mon, 27 Mar 2006 14:11:01 -0800, Programador
<Pr*********@discussions.microsoft.com> wrote:
I'm getting this error when running this program:
Cannot calculate rate using the arguments provided

Module Module1

Sub Main()

Rate(360, -694.44444444444446, 244274.69178082192)
End Sub

End Module

This is a vb console application, has anybody seen this before? how can I
fix this?

Mar 31 '06 #7

This discussion thread is closed

Replies have been disabled for this discussion.