VB2019 VB2017 VB2015 VB2013 VB2012 VB2010 VB2008 VB6 VB Sample Codes 中文VB About Us

Loan Payments Calculator

If you have taken a loan such as mortgage for a property you purchase, you often find it hard to calculate the monthly payments. Fortunately, you can create a loan payments calculator in Visual Basic 6. Visual basic 6 provides some very handy financial functions which makes  accounting and financial calculations effortless. Some of the financial functions are listed below.




Compute the payment for an annuity


Computes the interest payment for a certain period


Computes the principal payment


Computes internal rate of return for cash flows


Computes interest rate per period


Calculate the future value


Computes the present value


Computes net present value


Computes the number of periods for an annuity

To create a loan payment calculator, we can use the Pmt function. The format of Pmt is

Pmt(Rate, NPer, PV, FV,Due)

Rate=Interest rate, Nper=Number of payment periods, PV=present value, FV=future value, Due=set to 1 if payment due at the beginning of period and 0 for payment due at end of period.

The Runtime Interface

The Code

Private Sub cmd_Compute_Click()
Dim N As Integer
Dim amt, payment, rate As Double
amt = Val(Txt_loan.Text)
rate = (Val(Txt_Int.Text) / 100) / 12
N = Val(Txt_N.Text) * 12
payment = Pmt(rate, N, -amt, 0, 0)
Lbl_payment.Caption = Format(payment, "$#,##0.00")
End Sub


Normally people will just key in the annual interest rate as integer rather than as %, so we have to divide that rate by 100 and then by 12 to get the monthly interest. Why use negative sign for the present value(PV)? Because that is the amount we borrowed, so it must be negative. The future value is set to 0 because by then you have paid up all the payments. Finally, due is set to 0 as the payment is due at end of the month.


Copyright©2008 Dr.Liew Voon Kiong. All rights reserved |Contact|Privacy Policy