Results 1 to 2 of 2

Thread: HELP HELP HELP HELP Amortize results not displaying correctly in ListView

  1. #1

    Thread Starter
    New Member
    Join Date
    Apr 2014
    Posts
    2

    HELP HELP HELP HELP Amortize results not displaying correctly in ListView

    Hi All,

    I am hoping you can help me understand what I am missing or have incorrect in the below code. This is a simple loan calculator that in turn should display amortization schedule through the ListView. however, I am getting "some" data to return but it isn't correct. Can you please help me understand this as I have this as a project that I have to turn in this week. Any help will be greatly appreciated :-)

    Also, as shown below in the screenshot, it displays some of the data, but incorrectly.
    Code:
    Dim Num, n1 As Integer
    Dim I, P, PVIFA, r, lnpmt, PI, PP As Double
    
    
    Private Sub btnCalculate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCalculate.Click
            P = txtLoanAmount.Text
            Num = txtMonths.Text
            r = txtInterestRate.Text
            I = r / 100
            PVIFA = 1 / I - 1 / (I * (1 + I) ^ Num)
            lnpmt = P / PVIFA
            lblTotal.Text = Math.Round(lnpmt, 2)
    
            
        End Sub
        Private Sub btnAmortize_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnAmortize.Click
            Do
                n1 = n1 + 1
                PI = P * I
                PP = lnpmt - PI
                P = P - PP
                ListView1.Items.Add(n1.ToString())
                ListView1.Items.Add(PP.ToString("$,####.00"))
                ListView1.Items.Add(PI.ToString("C"))
                ListView1.Items.Add(P.ToString("$,####.00"))
                ListView1.Items.Add(lnpmt.ToString("$,####.00"))
                If P = 0 Then
                End If
                Exit Do
            Loop
        End Sub
    ATTACH]113115[/ATTACH]
    Attached Images Attached Images  

  2. #2
    Addicted Member
    Join Date
    Oct 2013
    Posts
    212

    Re: HELP HELP HELP HELP Amortize results not displaying correctly in ListView

    Apparently your formula is wrong, to begin with. This is how it should be.

    Let:

    A : Amount borrowed
    N : Number of months (in this example)
    I : Interest rate = I / 1200 (convert annual interest rate to monthly rate)
    P : Payment
    W : Principal

    The payment is calculated by this formula:

    P = (A x I)/(1-(1 + I)^(-N))

    Now that P is defined, let's calculate the other variables. Note that I'm just using
    pseudocode"

    For a As Integer = 1 To N
    If a <> N Then

    InterestAmount = A * I
    W = P - InterestAmount
    A = A - W

    Else

    InterestAmount = A * I
    W = A
    P = W + InterestAmount
    A = 0
    End If

    Next

    Good luck.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width