How do you do the actual calculations?
I have the rest of the code as follows.
Private Sub btnAnalyze_Click(sender As Object, e As EventArgs) Handles btnAnalyze.Click
'Define Variables
Dim loan As Double
Dim length As Double
Dim interest As Double
Dim monthly_payment As Double
Dim total_interest As Double
'Error Checking
If txtLoan.Text <= "0" Then
MessageBox.Show(" Please fill in the loan amount", "Missing Information")
ElseIf txtRate.Text <= "0" Then
MessageBox.Show(" Please fill in the interest rate", "Missing Information")
ElseIf txtLength.Text <= "0" Then
MessageBox.Show(" Please fill in the loan duration in months", "Missing Information")
'Compute
Else
End If
'Assign Values
loan = CDbl(txtLoan.Text)
length = CDbl(txtLength.Text)
interest = CDbl(txtRate.Text)
monthly_payment = loan * (interest / 12) / 1 - (1 + interest) ^ (-length)
total_interest = length * monthly_payment - loan
End Sub
End Class
Added (1). The formula for the monthly payment is:
Payment = p * r / (1 â" (1 + r) ^ (-n. ,
Where p is the amount of the loan, r is the monthly interest rate (annual rate divided by 12) given as a number between 0 (for 0 percent) and 1 (for 100 percent), and n is the duration of the loan in months. The formula for the total interest paid is:
total interest = n * payment â" p.
Read more: Analyze Mortgage in Visual Basic?