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
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.
How do I step through? I press Debug, then step through, then I tried pressing F8 but it wouldn't work.
Trip the formula and use msgboxs to show the current result... Some thing like this: Code: 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.
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=""