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)。

傳回

年金的每期利率。

例外狀況

NPer<= 0.

範例

這個範例會使用 函 Rate 式來計算貸款的利率,指定付款 TotPmts () 總數、貸款 Payment 付款金額 () 、貸款 () 的現值或主體、貸款 PValFVal (的未來值) 、指出付款是否在付款 (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值。

適用於

另請參閱