Financial.Rate(Double, Double, Double, Double, DueDate, Double) 方法

定义

返回一个指定每期年金利率的值。

public static double Rate (double NPer, double Pmt, double PV, double FV = 0, Microsoft.VisualBasic.DueDate Due = Microsoft.VisualBasic.DueDate.EndOfPeriod, double Guess = 0.1);
static member Rate : double * double * double * double * Microsoft.VisualBasic.DueDate * double -> double
Public Function Rate (NPer As Double, Pmt As Double, PV As Double, Optional FV As Double = 0, Optional Due As DueDate = Microsoft.VisualBasic.DueDate.EndOfPeriod, Optional Guess As Double = 0.1) As Double

参数

NPer
Double

必需。 年金付款总期数。 例如,如果您的汽车贷款的期限为四年,按月还款,则这笔贷款共有 4 * 12(即 48)个支付周期。

Pmt
Double

必需。 每期应付金额。 付款金额通常包含本金和利息,该值在年金的有效期限内都不会改变。

PV
Double

必需。 未来一系列支出或收入的现值。 例如,如果您贷款买车,贷款额就是您将以按月还款的方式付给贷方的现值。

FV
Double

可选。 完成最后一次付款后所希望的终值或现金余额。 例如,贷款的终值为 $0,这是因为终值是末期还款之后的价值。 但是,如果您想用 18 年的时间存储 $50,000 作为孩子的教育经费,则 $50,000 是终值。 如果省略,则假定为 0。

Due
DueDate

可选。 DueDate 类型的对象指定付款何时到期。 如果在付款期末付款,则此参数必须为 DueDate.EndOfPeriod;如果在付款期初付款,则此参数必须为 DueDate.BegOfPeriod。 如果省略,则假定为 DueDate.EndOfPeriod

Guess
Double

可选。 Rate 将返回估计值。 如果省略,Guess 便为 0.1 (10%)。

返回

Double

每期的年金利率。

例外

NPer<= 0.

示例

此示例使用 Rate 函数计算贷款的利率,给定付款 () TotPmts 总数、贷款支付 () 的金额、贷款 (Payment) PVal 的现值或本金、贷款 (FVal) 的未来价值、指示付款期 PayType 开始或结束时 () 以及 () Guess 的预期利率的近似值。

Sub TestRate()
    Dim PVal, Payment, TotPmts, APR As Double
    Dim PayType As DueDate

    ' Define percentage format.
    Dim Fmt As String = "##0.00"
    Dim Response As MsgBoxResult
    ' Usually 0 for a loan.
    Dim FVal As Double = 0
    ' Guess of 10 percent.
    Dim Guess As Double = 0.1
    PVal = CDbl(InputBox("How much did you borrow?"))
    Payment = CDbl(InputBox("What's your monthly payment?"))
    TotPmts = CDbl(InputBox("How many monthly payments do you have to make?"))
    Response = MsgBox("Do you make payments at the end of the month?", MsgBoxStyle.YesNo)
    If Response = MsgBoxResult.No Then
        PayType = DueDate.BegOfPeriod
    Else
        PayType = DueDate.EndOfPeriod
    End If
    APR = (Rate(TotPmts, -Payment, PVal, FVal, PayType, Guess) * 12) * 100

    MsgBox("Your interest rate is " & Format(CInt(APR), Fmt) & " percent.")
End Sub

注解

年金是一段时间内的一系列固定现金付款。 年金可以是贷款 (,如住房抵押贷款) 或投资 (,如每月储蓄计划) 。

对于所有参数,支付的现金 (如存款到储蓄) 用负数表示:收到的现金 (如股息检查) 由正数表示。

Rate 按迭代计算。 从 的值 Guess开始, Rate 循环执行计算,直到结果准确到 0.00001% 以内。 如果在 Rate 20 次尝试后找不到结果,则失败。 如果猜测为 10%,但 Rate 失败,请尝试为 Guess使用其他值。

适用于

另请参阅