VBA教程:NPer 函数示例(VBA)

2015-05-31 21:12 阅读 51 次 评论关闭

本示例使用 NPer 函数计算分期偿还贷款之总期数,贷款金额为 PVal。计算时尚需给定每期利率(APR / 12),每期付款金额(Payment),贷款的未来值(FVal)及付款方式,以数值表示期初或期末付款(PayType)。

Dim FVal, PVal, APR, Payment, PayType, TotPmts
Const ENDPERIOD = 0, BEGINPERIOD = 1   ' 付款方式。
FVal = 0   ' 对贷款而言通常为零。
PVal = InputBox("How much do you want to borrow?")
APR = InputBox("What is the annual percentage rate of your loan?")
If APR > 1 Then APR = APR / 100   ' 确保格式正确。
Payment = InputBox("How much do you want to pay each month?")
PayType = MsgBox("Do you make payments at the end of month?", vbYesNo)
If PayType = vbNo Then PayType = BEGINPERIOD Else PayType = ENDPERIOD
TotPmts = NPer(APR / 12, -Payment, PVal, FVal, PayType)
If IntTotPmts <> TotPmts Then TotPmts = IntTotPmts + 1
MsgBox "It will take you " & TotPmts & " months to pay off your loan."
版权声明:本文著作权归原作者所有,欢迎分享本文,谢谢支持!
转载请注明:VBA教程:NPer 函数示例(VBA) | 猎微网
分类:VBA 标签:, , ,

评论已关闭!