Hello everyone of DaniWeb!! I have an issue with the good old Mortgage Calculator I need to make this list, but i am not sure what i am doing wrong. any help? Here is the assignment

Write the program in VB.Net (not Web based) and have it accept user input of the amount, term and interest rate. Display the mortgage payment amount. Then, list the loan balance and interest paid for each payment over the term of the loan. The list will be longer than the screen, so use loops to display a partial list, hesitate, and then display more of the list. Insert comments to document the program.

Public Class MortCalc

    Private Sub clearForm()
        txtAmount.Text = "Enter Amount"
        txtRate.Text = "Enter Interest Rate"
        txtYears.Text = "Enter Years"
        txtMonthlyPayment.Text = ""
    End Sub

    Private Sub btnExit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnExit.Click
    End Sub

    Private Sub btnCalc_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCalc.Click
        'Calculate the Monthly Payment'
        Dim dblAmount, dblMonthlyRate, dblMonths, dblMonthlyPayment As Double
        'Convert input values to numeric values'
        dblAmount = CDbl(txtAmount.Text)
        dblMonthlyRate = CDbl(txtRate.Text) / 100 'allows interest rate to be entered whole number'
        dblMonths = CDbl(txtYears.Text)
        'Format input values'
        txtAmount.Text = FormatCurrency(dblAmount)
        txtRate.Text = FormatPercent(dblMonthlyRate)
        txtYears.Text = FormatNumber(dblMonths)
        'Calculate payment'
        'Results for listbox should be new loan balance and interest rate'
        Dim PVal, FVal, mPayments As Integer
        Dim APR, iPayment, TotInt As Double
        Dim pPayment, TotPrincipal, dblBalance As Double
        PVal = dblAmount
        FVal = 0
        APR = dblMonthlyRate / 12
        mPayments = dblMonths * 12
        dblBalance = dblAmount
        For period As Integer = 1 To mPayments
            iPayment = IPmt(APR, period, mPayments, -PVal, FVal, 1)
            pPayment = PPmt(APR, period, mPayments, -PVal, FVal, 1)
            lstLoanInterest.Items.Add(FormatCurrency(TotPrincipal).PadRight(25) & FormatCurrency(iPayment).PadRight(25) & FormatCurrency(dblBalance).PadLeft(25))
            Debug.WriteLine(" Pmnt #" & period & " -> Principle =" & FormatCurrency(TotPrincipal).PadRight(14) & " Int Paid for Payment #" & period & "  is " & FormatCurrency(iPayment) & "  Bal. =" & FormatCurrency(dblBalance))
            TotInt = TotInt + iPayment
            TotPrincipal = TotPrincipal + pPayment
            Dim monthlyPayment As Double = CDbl(iPayment + pPayment)
            dblBalance = dblBalance - (monthlyPayment - iPayment)
        lstLoanInterest.Items.Add(" _______________________________")
        lstLoanInterest.Items.Add(" Total interest paid: " & FormatCurrency(TotInt))
        lstLoanInterest.Items.Add(" _______________________________")
        lstLoanInterest.Items.Add(" Total Paid after: " & mPayments & "  Payments = " & FormatCurrency(TotInt + TotPrincipal))
        lstLoanInterest.Items.Add(" _______________________________")
        lstLoanInterest.Items.Add(" Last Payment is an interest payment of course, and it is " & FormatCurrency(iPayment))
        'Format answer'
        dblMonthlyPayment = CDbl(iPayment + pPayment)
        txtMonthlyPayment.Text = FormatCurrency(dblMonthlyPayment)
    End Sub

    Private Sub btnClear_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnClear.Click
    End Sub
End Class
7 Years
Discussion Span
Last Post by hollywoood69
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.