Financial 模組 (Visual Basic)
更新:2007 年 11 月
Financial 模組會包含用於執行財務作業的程序。
備註
這個模組支援執行財務運算的 Visual Basic 執行階段程式庫成員,例如折舊、目前和未來價格、利率、報酬率和付款。
成員
|
|
|
範例
這個範例會使用 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