Building a Loan Payment Calculator using ASP.NET 2.0
(Page 1 of 5 )
Making payments to loans for a home or a car is a fact of life. This tutorial is about creating a loan calculator using ASP.NET 2.0. We will be looking at fixed interest loans which are normally quoted for 30, 15, and 10 years.
This type of loan requires you to pay back equal installments over the period of the loan. In the early part of your loan you will be paying more interest and less principal, and towards the end of the loan period more principal and less interest. There is a plethora of financial loan products apart from this kind of loan. What is assumed in the fixed interest loan is that the rate does not vary during the life of the loan.
In this tutorial we will be asking the question, suppose one borrows $10,000.00 at an interest of eight percent per annum (per year), to be paid back in 10 months -- what will the monthly payment be? Since banks and loan companies want you to pay on a fixed date each month, your payment may vary depending on whether you make the payment at the beginning of the pay period or the end.
The interest rate, present value of a loan, future value of a loan, the agreed-to number of payments and the payment per payment period are all inter-related. These are represented by functions in Microsoft Visual Basic. The graphic user interface packages this function in an application with some validation.
The Financial Web Site
Start a new web site from the file menu. In this tutorial it is called the Financials, at http://localhost/Financials. Add a web page. This page will be named finPMT.aspx and is the container for your loan payment calculator. In ASP.NET 2.0, in addition to other system namespaces you also have the Microsoft.VisualBasic. The various financial variables used in this application can all be located on the Object Browser as shown in this picture. The highlighted object is the PMT function that will be used. There is a lengthy explanation of how this function works. The arguments that go into this function are clearly explained.

The PMT Function basics
The definition of this function as seen in the object browser is as follows:
Public Function Pmt (ByVal Rate As Double,
ByVal Nper As Double,
ByVal PV As Double,
Optional ByVal FV As Double = 0.0
Optional ByVal Due As
Microsoft.VisualBasic.DueDate = _
EndOfPeriod) As Double
The graphic user interface will take the input from the text boxes for the Rate, Nper, PV, FV, and DueDate. This is inserted into the above formula and the result is the payment (PMT) that must be paid each period. Since the values that are entered into text boxes are of the string type you will need to convert them to the proper data type. Hence some data conversions are necessary.
Next: The description of the payment calculator >>
More ASP.NET Articles
More By Jayaram Krishnaswamy