Requirements:
Loan Amount Text Box
Fixed Interest Rate Text Box
Years Combo Box
To be calculated:
Monthly Payments
Number of Payments
Payment Total
Interest Total
Buttons:
Calculate and Exit
I have the correct calculations appearing in the Monthly Payments and Number of Payments. But when I try to use a pmt function for payment total and interest total, I can't get it to work. They way I have it constructed to calculate those two fields, the math is off from the calculators I am using to help work the math to check it. Online Calculator
Here is my code... Things I need assistance on: Payment Total And Interest Total. Either help with how to do the pmt function or help with fixing my code that I currently have.
Public Class Form1
Dim Nullable As TextBox
Private Sub Form_load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Me.cboYears.SelectedText = "30"
End Sub
Private Sub btnExit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnExit.Click
Me.Close()
End Sub
Private Sub btnCalc_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCalc.Click
'Ensure that fields are entered to stave off errors running program.
If String.IsNullOrEmpty(txtLoanAmount.Text) Then
MessageBox.Show("Missing Amount", "Please Enter Amount of Loan")
ElseIf String.IsNullOrEmpty(txtInterestRate.Text) Then
MessageBox.Show("Missing Interest", "Please Enter Fixed Interest Rate")
Else
Dim LoanAmount As Double
Dim InterestRate As Double
Dim Years As Double
Dim Months As Double
LoanAmount = CDbl(txtLoanAmount.Text)
InterestRate = txtInterestRate.Text / 12
Years = CDbl(cboYears.Text)
Months = cboYears.Text * 12
'Monthly Payment Calculations and Number of Monthly Payments.
txtMonthPayment.Text = Pmt(InterestRate, Months, -LoanAmount)
txtMonthPayment.Text = Format(CDbl(txtMonthPayment.Text), "$###,###,###.##")
txtNumPayment.Text = Months
'Payment Total Calculations.
txtPaymentTotal.Text = txtMonthPayment.Text * txtNumPayment.Text
txtPaymentTotal.Text = Format(CDbl(txtPaymentTotal.Text), "$###,###,###.##")
'Total of Interests Paid.
txtInterestTotal.Text = txtPaymentTotal.Text - txtLoanAmount.Text
txtInterestTotal.Text = Format(CDbl(txtInterestTotal.Text), "$###,###,###.##")
End If
End Sub
End Class
One common problem I get when trying to do pmt function with the payment total is an error about infinite number. Which I thought was weird, so I figured I was blowing something up. I can't find a clear post about how pmt function works, or a post where someone did a similar mortgage calculator.
Thanks!

New Topic/Question
Reply




MultiQuote






|