HarlessSmithIA3.zip (125.77K)
Number of downloads: 90This program is supposed to calculate the ever popular mortgage payment and amortize the loan in a list box. I keep throwing this error "Missing Member Exception" and can not find out how to fix it anywhere. Because of the error I can't even see if I can even get a calculation in the text box, let alone if the amortization will run. The purple text is where the exception is. Any help would be appreciated.
Public Class HarlessSmithIA3
Dim LoanAmt, Int, Result, Term As Double
Dim txtIntRate As New Object
Dim txtLoanAmount As New Object
Dim txtLoanTerm As New Object
Dim txtMonthlyPayment As New Object
Private Sub ExitButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ExitButton.Click
'Exit Program
Me.Close()
End Sub
Private Sub Calc_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCalculate.Click
'Calculate the Monthly Payment
Dim LoanAmount As Double 'loan amount
Dim IntRate As Integer 'interest rate
Dim LoanTerm As Integer 'number of years
Dim MonthlyPayment As Double 'payment amount
txtLoanAmount.Text = FormatCurrency(LoanAmount)
txtIntRate.Text = FormatPercent(IntRate)
txtLoanTerm.Text = FormatNumber(LoanTerm)
[color="#800080"]LoanAmount = CDbl(txtLoanAmount.Text)
IntRate = CDbl(txtIntRate.Text) / 100
LoanTerm = CDbl(txtLoanTerm.Text) * 12
MonthlyPayment = (txtMonthlyPayment.ToString)[/color]
MonthlyPayment = Pmt(txtIntRate / 12, txtLoanTerm * 12, txtLoanAmount * -1)
End Sub
Private Sub Amort_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Amort.SelectedIndexChanged
Dim LoanAmount, IntRate, MonthlyPayment, LoanTerm As Double
Dim PVal, FVal, mPayments As Integer
Dim APR, iPayment, TotInt As Double
Dim pPayment, TotPrincipal, Balance As Double
PVal = LoanAmount
FVal = 0
APR = IntRate / 12
mPayments = LoanTerm * 12
Balance = LoanAmount
For period As Integer = 1 To mPayments
iPayment = IPmt(APR, period, mPayments, -PVal, FVal, 1)
pPayment = PPmt(APR, period, mPayments, -PVal, FVal, 1)
Amort.Items.Add(FormatCurrency(TotPrincipal).PadRight(25) & FormatCurrency(iPayment).PadRight(25) & FormatCurrency(Balance).PadLeft(25))
Debug.WriteLine(" Pmnt #" & period & " -> Principle =" & FormatCurrency(TotPrincipal).PadRight(14) & " Int Paid for Payment #" & period & " is " & FormatCurrency(iPayment) & " Bal. =" & FormatCurrency(Balance))
TotInt = TotInt + iPayment
TotPrincipal = TotPrincipal + pPayment
MonthlyPayment = CDbl(iPayment + pPayment)
Balance = Balance - (MonthlyPayment - iPayment)
Next
Amort.Items.Add(" _______________________________")
Amort.Items.Add(" Total interest paid: " & FormatCurrency(TotInt))
Amort.Items.Add(" _______________________________")
Amort.Items.Add(" Total Paid after: " & mPayments & " Payments = " & FormatCurrency(TotInt + TotPrincipal))
Amort.Items.Add(" _______________________________")
Amort.Items.Add(" Last Payment is " & FormatCurrency(iPayment))
'Format answer'
MonthlyPayment = CDbl(iPayment + pPayment)
txtMonthlyPayment.Text = FormatCurrency(MonthlyPayment)
End Sub
Private Sub VScrollBar1_Scroll(ByVal sender As System.Object, ByVal e As System.Windows.Forms.ScrollEventArgs) Handles VScrollBar1.Scroll
End Sub
End Class

New Topic/Question
Reply




MultiQuote





|