A1VBCode Forums

Visual Basic Loan Calculator with Functions


http://www.a1vbcode.com/vbforums/Topic32148.aspx

By lighthelamp - 3/26/2014

I need to build a Loan Calculator that uses functions to provide the values, for the text boxes, based on what radio button is clicked. Then i need to use a Sub to report the result with a label.



I think i am started off in the right direction but i have no background in vb so please bear with me.





Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click

Dim Payment As Double

Dim Nper As Double

Dim LoanIRate As Double

Dim LoanDuration As Integer

Dim LoanAmount As Integer





If rdbmp1.Checked Then

Payment = Pmt(LoanIRate, LoanDuration, -LoanAmount, 0, )

TextBox4.Text = Payment.ToString("#.00")

End If

If rdbamt1.Checked Then

LoanAmount = PV(LoanIRate / 1200, LoanDuration, -Payment)

TextBox1.Text = Payment.ToString("#.00")

End If

If rdbir1.Checked Then

LoanIRate = 1200 * Rate(LoanDuration, Payment - LoanAmount)

TextBox2.Text = Payment.ToString("#.00")

End If

If rdbdl1.Checked Then

LoanDuration = Nper(LoanIRate / 1200, Payment, -LoanAmount)

TextBox3.Text = Payment.ToString("#.00")

End If

End Sub



At the moment the only calculation that is working for me correctly is the monthly payment, all of the others have build errors.
By zack - 3/26/2014

Provide the code for your functions.