Building a Loan Payment Calculator using ASP.NET 2.0 - The code behind the finPMT.aspx page
(Page 3 of 5 )
This code file is called the finPMT.aspx.vb. It contains the code for the events that are invoked by the finPMT.aspx page, like loading the page, clicking the mouse, and so forth. The next paragraph shows the code that is executed when the button is clicked.
Partial Class finPMT
Inherits System.Web.UI.Page
Protected Sub Button1_Click(ByVal sender As Object, ByVal _
e As System.EventArgs) Handles Button1.Click
Dim dfpmt As Double
If rbStart.Checked Then
dfpmt = Pmt(CDbl((txtRate.Text) * (0.01 / 12)), _
CDbl(txtNper.Text), CDbl(txtPV.Text), _
CDbl(txtFV.Text), DueDate.BegOfPeriod)
Else
If rbEnd.Checked Then
dfpmt = Pmt(CDbl((txtRate.Text) * (0.01 / 12)), _
CDbl(txtNper.Text), CDbl(txtPV.Text), _
CDbl(txtFV.Text), DueDate.EndOfPeriod)
End If
End If
TextBox1.Text = Format(dfpmt, "$##,######.00")
End Sub
End Class
Testing the page
Right click the finPMT.aspx in the solution explorer and click on the drop-down menu item named View in Browser. This brings up the aspx page in the IE browser. For starters just insert the test values and verify that the payment from the payment calculator matches the one shown under Test Values.

Next: Use of validation controls >>
More ASP.NET Articles
More By Jayaram Krishnaswamy