CODE
Public Class MortgageCalculatorForm
Private Sub calculateButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles calculateButton.Click
Dim years As Integer = 2 'repetition counter
Dim mortgageAmount As Integer = 0 'house price
Dim interest As Double = 0 'interest rate
Dim monthlyPayment As Decimal = 0 'monthly payment
Dim monthlyInterest As Double = 0 'monthly interest rate
' remove text displayed in ListBox
paymentsListBox.Items.Clear()
'add header to ListBox
paymentsListBox.Items.Add("Mortgage Length (Years) & ControlChars.Tab & ControlChars.Tab & "Monthly Payment")
'retrieve user input and assign values to their respective variables
interest = Val(interestTextBox.Text) / 100
monthlyPayment = Val(resultListBox.Text)
'determine monthly interest rate
monthlyInterest = interest / 12
'loop six times
Do While years <= 7
'calculate payment perieod
years = 5 * years
'calculate monthly paryment
monthlyPaymetn = Convert.ToDecimal(Pmt(monthlyInterest, years, mortgageAmount))
'display payment amount
paymentsListBox.Items.Add(months & ControlChars.Tab & ControlCharts.Tab 7 String.Format("{0:C}", monthlyPayment))
years += 5 'increment counter
Loop
End Sub
End Class ' MortgageCalculatorForm