Results 1 to 15 of 15

Thread: [RESOLVED] POS - What is wrong with my math?

  1. #1

    Thread Starter
    WiggleWiggle dclamp's Avatar
    Join Date
    Aug 2006
    Posts
    3,527

    Resolved [RESOLVED] POS - What is wrong with my math?

    ok the following is code to add tax to the transaction. It is not coming out correctly...
    VB Code:
    1. intSubTotal = (Val(txtStateTax.Text) * Val(txtSubTotal.Text))
    2.     frmPOS_Finish.txtGrandTotal.Text = (Val(txtSubTotal.Text) + Val(intSubTotal))
    3.     frmPOS_Finish.txtGrandTotal.Text = Format(frmPOS_Finish.txtGrandTotal.Text, "#,###.##0")
    My usual boring signature: Something

  2. #2
    Frenzied Member
    Join Date
    Oct 2003
    Posts
    1,301

    Re: POS - What is wrong with my math?

    What is going wrong?
    What is the value of txtStateTax? Greater than 1?

  3. #3

  4. #4
    PowerPoster RhinoBull's Avatar
    Join Date
    Mar 2004
    Location
    New Amsterdam
    Posts
    24,132

    Re: POS - What is wrong with my math?

    Quote Originally Posted by dclamp
    ... What is wrong with my math? ...
    Where to begin?..

    - intSubTotal needs to be declared as Currency or Single or Double or decimals will be rounded
    - Val(intSubTotal) makes no sense since intSubTotal is already numeric
    - Val() function returns only numeric values until first non-numeric character is found
    - you may need to experiment with the different formats

  5. #5

  6. #6

    Thread Starter
    WiggleWiggle dclamp's Avatar
    Join Date
    Aug 2006
    Posts
    3,527

    Re: POS - What is wrong with my math?

    Quote Originally Posted by MartinLiss
    How is txtStateTax formatted? .10? 10?

    7.25
    My usual boring signature: Something

  7. #7
    Frenzied Member
    Join Date
    Oct 2003
    Posts
    1,301

    Re: POS - What is wrong with my math?

    Which would result in 7.25 times the price for VAT. (725 % )

    As mentioned, divide it by 100.

  8. #8

  9. #9

  10. #10

    Thread Starter
    WiggleWiggle dclamp's Avatar
    Join Date
    Aug 2006
    Posts
    3,527

    Re: POS - What is wrong with my math?

    Like this?

    VB Code:
    1. intSubTotal = (Val(txtStateTax.Text) / Val("100")) * (val(txtSubTotal.text))
    2. frmPOS_Finish.txtGrandTotal.Text = (Val(txtSubTotal.Text) + Val(intSubTotal))
    3. frmPOS_Finish.txtGrandTotal.Text = Format(frmPOS_Finish.txtGrandTotal.Text, "#,###.##0")
    My usual boring signature: Something

  11. #11

    Thread Starter
    WiggleWiggle dclamp's Avatar
    Join Date
    Aug 2006
    Posts
    3,527

    Re: POS - What is wrong with my math?

    Quote Originally Posted by RhinoBull
    NO wonder result is incorrect. Did you read my first reply yet?

    oh of course, but I got Lost though...
    My usual boring signature: Something

  12. #12
    Frenzied Member
    Join Date
    Oct 2003
    Posts
    1,301

    Re: POS - What is wrong with my math?

    Why use X / Val("100")?
    Just use X / 100.
    Saves the computer needless work.

  13. #13

    Thread Starter
    WiggleWiggle dclamp's Avatar
    Join Date
    Aug 2006
    Posts
    3,527

    Re: POS - What is wrong with my math?

    ok, other then that, it is ok?
    My usual boring signature: Something

  14. #14

  15. #15

    Thread Starter
    WiggleWiggle dclamp's Avatar
    Join Date
    Aug 2006
    Posts
    3,527

    Re: POS - What is wrong with my math?

    ok, thanks guys!
    My usual boring signature: Something

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width