[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:
intSubTotal = (Val(txtStateTax.Text) * Val(txtSubTotal.Text))
frmPOS_Finish.txtGrandTotal.Text = (Val(txtSubTotal.Text) + Val(intSubTotal))
frmPOS_Finish.txtGrandTotal.Text = Format(frmPOS_Finish.txtGrandTotal.Text, "#,###.##0")
Re: POS - What is wrong with my math?
What is going wrong?
What is the value of txtStateTax? Greater than 1?
Re: POS - What is wrong with my math?
How is txtStateTax formatted? .10? 10?
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
Re: POS - What is wrong with my math?
If it's 10 you need to divide by 100.
Re: POS - What is wrong with my math?
Quote:
Originally Posted by MartinLiss
How is txtStateTax formatted? .10? 10?
7.25
Re: POS - What is wrong with my math?
Which would result in 7.25 times the price for VAT. (725 % :eek: )
As mentioned, divide it by 100.
Re: POS - What is wrong with my math?
Quote:
Originally Posted by dclamp
7.25
So you need to divide by 100.
Re: POS - What is wrong with my math?
Quote:
Originally Posted by dclamp
7.25
NO wonder result is incorrect. Did you read my first reply yet?
Re: POS - What is wrong with my math?
Like this?
VB Code:
intSubTotal = (Val(txtStateTax.Text) / Val("100")) * (val(txtSubTotal.text))
frmPOS_Finish.txtGrandTotal.Text = (Val(txtSubTotal.Text) + Val(intSubTotal))
frmPOS_Finish.txtGrandTotal.Text = Format(frmPOS_Finish.txtGrandTotal.Text, "#,###.##0")
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...
Re: POS - What is wrong with my math?
Why use X / Val("100")?
Just use X / 100.
Saves the computer needless work.
Re: POS - What is wrong with my math?
ok, other then that, it is ok?
Re: POS - What is wrong with my math?
If it gives you the right result then it's right. BTW you seem to be infatuated with Val. Just use 100, there's no need for Val("100").
Re: POS - What is wrong with my math?