Newbie Question

Hi, this is my first post on this great site. I have started playing around with the desktop version and am trying to make a loan formula, but I must be getting the syntax wrong.

Here is what it's supposed to look like:

Payment = (Rate + (Rate / ((1 + Rate) ^ Months) * -1)) * Principal

For some reason when I enter it like that I get a syntax error. I believe that my use of negative one is the problem.

I appreciate any help.
Thanks!
Steve
 

Cableguy

Expert
Licensed User
Longtime User
Heve you tried to do the math step by step so that you can pinpoint the trouble bit?
 
Yes, and that's why I think the Negative one part is the problem.

This is just a calculation for a standard car loan.

Thanks for helping.
 

Cableguy

Expert
Licensed User
Longtime User
have you trried to wrap the negative one in parentesis as (-1)?
 

Cableguy

Expert
Licensed User
Longtime User
Trip the formula and use msgboxs to show the current result...
Some thing like this:
B4X:
Payment=(1 + RATE)* (-1) 'This should be the critic part, if you can pass this then all ok...
MSGBOX(payment)
Payment=(Payment+Rate) 'I don't know how you are implemeting the rate...But you should not introduce a percentage in a direct calculation...
MSGBOX(payment)

Payment = Payment * Principal

If I recal correctly, from my math lessons, multiplying by a negative number is equal to dividing by that absolut number(?)
Rate SHOULD not be in percentage, but represent the ratio...
 
I figured it out. I made an error. I was supposed to subtract 1, not multiply by negative one. Here's my final code:

Sub cmdCalc_Click
Dim Prin
Dim Rate
Dim Term
Dim MonthlyRate
Dim Payment
Dim Middle
Dim bottom



Prin = txtPrin.Text
Rate = txtRate.Text / 1200
Term = txtLength.Text * 12

bottom = ((1 + Rate) ^ (Term ))
bottom = bottom - 1
middle = Rate / bottom
Payment = (Rate + middle) * Prin

lblOut.Text = Payment

Thanks for the help.
 

Cableguy

Expert
Licensed User
Longtime User
I figured it out. I made an error. I was supposed to subtract 1, not multiply by negative one. Here's my final code:

Sub cmdCalc_Click
Dim Prin
Dim Rate
Dim Term
Dim MonthlyRate
Dim Payment
Dim Middle
Dim bottom

There's no need to "Dim" normal variables....
You can just use the without previous settings...
If you need to share a variable bettween several subs, then put them in the Global sub, like this:

Prin=""
Rate=""
Term=""
MonthlyRate=""
Payment=""
Middle=""
bottom=""
 
Top