# Mortgage Calculator help

• ### Question

• ```Public Class Mortgage_Calculator_Change_16

Private Sub Calculate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Calculate.Click

Dim a, r, t, m As Double

If IsNumeric(TextBox1.Text) Then ' This is the location for the dollar amount
a = Convert.ToDouble(TextBox1.Text)

TextBox1.Focus()
TextBox1.SelectAll()
End If

If IsNumeric(TextBox2.Text) Then ' loan term
t = Convert.ToDouble(TextBox2.Text) * 12 ' converts years to months

TextBox2.Focus()
TextBox2.SelectAll()
End If

If IsNumeric(TextBox3.Text) Then ' interest rate
r = 0.01 * Convert.ToDouble(TextBox3.Text) / 12 ' monthly interest rate as a decimal

TextBox3.Focus()
TextBox3.SelectAll()
End If

m = Pmt(r, t, -a, 0)
TextBox4.Text = m.ToString("\$#.00")

End Sub

Private Sub Breakdown_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Breakdown.Click
' display loan repayment breakdown.  remaining Balance and Interest paid
Dim b, i, p, mr As Double

b = (TextBox1.Text) - (TextBox4.Text) ' remaining balance
mr = 0.01 * Convert.ToDouble(TextBox3.Text) * 12 ' Monthly Interest Rate
i = (TextBox4.Text) * (mr) ' interest payment
p = (TextBox4.Text) - (i) ' ammouint paid on principal

End Sub
Private Sub Exit_Button_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Exit_Button.Click

' exit program

Me.Close()

End Sub

End Class```

I am working on a program to Figure Mortgage Rates and have it accept user input of the amount, term and interest rate. Display the mortgage payment amount. Then, list the loan balance and interest paid for each payment over the term of the loan. The list will be longer than the screen, so use loops to display a partial list, hesitate, and then display more of the list. Insert comments to document the program.

I have a Basic Program together that uses 2 buttons to created to requested output.  the First listed as Calculate figures the monthly payment. That workes great.

The second is listed as Breakdown, and that is where I am getting stuck.  I have the basic concept for it I just dont know how to get it to putput what I am trying to compute.

Any help would be great.

Monday, November 19, 2012 3:23 AM

• I agree that you can use a listbox of DataGridview.  I chose a richTextbox onl;y because you already  had a textbox. You need a control with a scroll bar.  I just don't understand why you think that a rich textbox couln't be used?  If the inputs get changed you simply would clear the data from the RichTextbox and fill it with new data.  You could even open Notepad or wordpad and store the results very easily so you can compare results.

Whatt is nice with a DataGridview or ListView is you can keep the old data and add a new column as you change the inputs to compare results.

jdweng

Monday, November 19, 2012 10:41 PM

### All replies

• Use a Richtextbox instead of a textbox which has a scroll bar.  Add text to the box using the following

Richtextbox1.AppendText("abc\n")     The \n will add a return for each line.

jdweng

Monday, November 19, 2012 6:40 AM
• What I am looking at providing is an Amortization Table Loop in the program.  I dont think that a rich text box would do that.  I think that a list box or a Data Grid would work better.
Monday, November 19, 2012 8:06 PM
• What I am looking at providing is an Amortization Table Loop in the program.  I dont think that a rich text box would do that.  I think that a list box or a Data Grid would work better.
Use a ListView or an owner drawn ListBox to display grid type data not bound to a database.

• Edited by Monday, November 19, 2012 10:01 PM
Monday, November 19, 2012 10:01 PM
• I agree that you can use a listbox of DataGridview.  I chose a richTextbox onl;y because you already  had a textbox. You need a control with a scroll bar.  I just don't understand why you think that a rich textbox couln't be used?  If the inputs get changed you simply would clear the data from the RichTextbox and fill it with new data.  You could even open Notepad or wordpad and store the results very easily so you can compare results.

Whatt is nice with a DataGridview or ListView is you can keep the old data and add a new column as you change the inputs to compare results.

jdweng

Monday, November 19, 2012 10:41 PM