Newbie Question

Discussion in 'Questions (Windows Mobile)' started by Stevenator65, May 30, 2008.

  1. Stevenator65

    Stevenator65 Member

    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.
  2. Cableguy

    Cableguy Expert Licensed User

    Heve you tried to do the math step by step so that you can pinpoint the trouble bit?
  3. Stevenator65

    Stevenator65 Member

    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.
  4. Cableguy

    Cableguy Expert Licensed User

    have you trried to wrap the negative one in parentesis as (-1)?
  5. Stevenator65

    Stevenator65 Member

    How do I step through? I press Debug, then step through, then I tried pressing F8 but it wouldn't work.
  6. Cableguy

    Cableguy Expert Licensed User

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

    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...
  7. Stevenator65

    Stevenator65 Member

    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.
  8. Cableguy

    Cableguy Expert Licensed User

    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:

  9. Stevenator65

    Stevenator65 Member

    Thanks again Cableguy. I'm starting to like this software, and the forum is top notch.
  10. Cableguy

    Cableguy Expert Licensed User

    Glad to ear that, and always glad to help...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice