Hello , I am working on getting this Mortgage repayment calculation code to work for my Access07DB, the code for was copied from some 2006 post on a vb forum. But some things I cant get to work
I will put the bad lines in red
Option Compare Database Private Sub CmdMortgageCalc_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CmdMortgageCalc.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 mPaymentsiPayment = 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 monthlyPayment = CDbl(iPayment + pPayment) dblBalance = dblBalance - (monthlyPayment - iPayment) Next 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
(bad rolf harris impersination) "Cenya tell wat it is yet?"
would really really apreciate if someone can see the glitches