## 16 Replies - 24681 Views - Last Post: 01 October 2008 - 02:01 PM

### #1

# mortgage calculator

Posted 26 September 2008 - 09:13 AM

there are 6 input text boxes :::: home value, loan amount, term(years), home insurance, property tax, and interest rate

and one read only text box that is monthly payment....

# P = principal, the initial amount of the loan

# I = the annual interest rate (from 1 to 100 percent)

# L = length, the length (in years) of the loan, or at least the length over which the loan is amortized.

The following assumes a typical conventional loan where the interest is compounded monthly. First I will define two more variables to make the calculations easier:

# J = monthly interest in decimal form = I / (12 x 100)

# N = number of months over which loan is amortized = L x 12

Okay now for the big monthly payment (M) formula, it is:

M = P x ( J/(1-(1-J)^-N)))

i can not get these numbers to come out correctly.....i am not very good at math.....

can someone please send me code for just the calculations on how to do this....

##
**Replies To:** mortgage calculator

### #2

## Re: mortgage calculator

Posted 26 September 2008 - 10:57 AM

Sorry, we're not just going to

*send you the code*. We will help as soon as you show us what you've done to solve this, but we're not going to do this for you

### #3

## Re: mortgage calculator

Posted 26 September 2008 - 11:08 AM

**[**rules

**]**

**[**/rules

**]**

### #4

## Re: mortgage calculator

Posted 26 September 2008 - 07:59 PM

Public Class Form1 Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim p As Double Dim i As Double Dim l As Double Dim m As Double Dim j As Double Dim n As Double i = txtinterest.Text p = txtloan.Text l = txtterm.Text j = i / (1200) n = l * 12 m = (p * (j / (1 - (1 + j) ^ -n))) txtpayment.Text = CDbl(m) End Sub End Class

This post has been edited by **milton7888**: 26 September 2008 - 08:01 PM

### #5

## Re: mortgage calculator

Posted 27 September 2008 - 12:37 PM

### #6

## Re: mortgage calculator

Posted 27 September 2008 - 02:12 PM

You said there is 6 inputboxes, from this code i cannot see how that would be necessary.

From what you have posted, i can only see the need for four.

txtLoan, txtInterest, txtTerm and txtPayment

If by input boxes you mean your variables (i am not calling you an idiot, im simply assuming a mistake could possibly be made and there are 6 variables) well if you read the code, its clear to see they are all being used.

n = l * 12

Term should be inputted as yearly. I mention this as it could possibly cause problems, maybe this is the error?

I have also built your application, but instead of making every input box i simply change the values.

debug your code, for the values, have txtinterest at 10, txtloan at 4000 and txtterm at 2. This would be a £4000 loan over a period of 2 years at 10%. Your txtpayment should say: 184.579705350067

Maybe this is your problem? then simply change:

m = (p * (j / (1 - (1 + j) ^ -n))) txtpayment.Text = CDbl(m)

To:

m = Math.Round((p * (j / (1 - (1 + j) ^ -n))), 2) payment.Text = CStr(m)

Hope it helps

Oops forgot to say why,

The Math.Round (Number, Dec Points) expression, well it rounds 'number' to however many decimal points you state with 'dec point'.

Anyway, i hope i've solved your problem in their somewhere

### #7

## Re: mortgage calculator

Posted 27 September 2008 - 04:31 PM

Quote

but if your only using 3 of the inputs why do you need the other three?

Although i have no idea how to work out the mortgage value, do you need to take into account those other factors? Maybe your not getting the right output is because your not including the tax and insurance and initial home value. But from just having a look at an example i'd say the formula is right. What sample data are you using? have a look here

http://www.sorted.or...ments/page2.php

and try use your data and see how it matches up against the output you get from you app

but my two cents is : try using more descriptive variable names when coding. It can save you a lot of headache and it makes it a lot easier for other people to read and help. Labeling things p and j etc is just painful

This post has been edited by **Damage**: 27 September 2008 - 04:46 PM

### #8

## Re: mortgage calculator

Posted 27 September 2008 - 05:07 PM

Quote

The following formula is used to calculate the fixed monthly payment (P) required to fully amortize a loan of L dollars over a term of n months at a monthly interest rate of c. [If the quoted rate is 6%, for example, c is .06/12 or .005].

P = L[c(1 + c)n]/[(1 + c)n - 1]

The next formula is used to calculate the remaining loan balance ( B ) of a fixed payment loan after p months.

B = L[(1 + c)n - (1 + c)p]/[(1 + c)n - 1]

try this

This post has been edited by **Damage**: 27 September 2008 - 05:14 PM

### #9

## Re: mortgage calculator

Posted 28 September 2008 - 05:59 AM

i must be missing some formulas or something.....

i sent a few of u a message with some example numbers, let me know if ne of u can help an ill send you some example numbers.....thanks

math blows

### #10

## Re: mortgage calculator

Posted 28 September 2008 - 08:44 AM

I'll take a look at the examples you sent me. I'm a bit busy at the moment, so i'll get to it in about an hour or two.

### #11

## Re: mortgage calculator

Posted 28 September 2008 - 06:11 PM

### #12

## Re: mortgage calculator

Posted 28 September 2008 - 08:35 PM

### #13

## Re: mortgage calculator

Posted 28 September 2008 - 09:15 PM

jacobjordan, on 28 Sep, 2008 - 08:35 PM, said:

hahah, yeah dont worry, about it, im lost, im slowly, giving up.....ill figure something out,

if ne one else wants to help or has input let me know....

### #14

## Re: mortgage calculator

Posted 29 September 2008 - 06:31 AM

*what information where you given ?*

**EXACTLY**### #15

## Re: mortgage calculator

Posted 01 October 2008 - 12:41 PM

Private Sub loan() Dim L As Double = 125000D 'loan amount Dim rate As Double = 6.375D 'interest rate Dim c As Double = (rate / 100D) / 12 'monthly interest rate Dim Nyear As Double = 30 'length of loan in years Dim n As Double = Nyear * 12 'length of loan in months Dim P As Double 'the payment P = Microsoft.VisualBasic.Financial.Pmt(c, n, -L) End Sub