Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how can I add gasoline prices usine the 0.00.9 9/10th 3

Status
Not open for further replies.

Skorkpup

Programmer
Feb 17, 2005
11
I am trying to add gasoline prices and have them displayed in a text box. but how can I compute the one tenth of a penny?

Such as ($3.25.9 plus $3.25.9) would return ($6.51.8).

in an ideal world a user would imput the price of gas into a text box. the results would go to a listview, and the listview would return the total column of such inputs to another text box. but how in the world can I add together 9/10ths of a penny? or get it to display?

Any help would be greatly appreciated.

Skorkpup
 
Skorkpup,

Can't you just get rid of the second decimal point? This is mathematically incorrect anyway and just seems to be complicating your issue.

If you want the system to display them both use the format and/or input mask properties to do this, but strip them out for the purpose of the calculation....

HTH,

Ed Metcalfe.

Please do not feed the trolls.....
 
As Ed2020 says, if you really want to see it with 2 decimal points, use an input mask like !\$0.00.0;;0 on your text box. Then, if you enter 3259 in the text box, you will see this as $3.25.9 and the .value of the box will be 3259. A simple matter of dividing the .value by 1000 will give you the mathematical result 3.259 which is correct.

If all you want to do is add two of these text box values together, you can take (text1.value + text2.value)/1000 as the actual mathematical result and just text3.value=(Text1.value + text2.value) to display the $6.51.8 result in the text3 box.
 
The problem I see is that the user enters the value in the textbox and before the listview value can be updated the price goes up again:)


Two strings walk into a bar. The first string says to the bartender: 'Bartender, I'll have a beer. u.5n$x5t?*&4ru!2[sACC~ErJ'. The second string says: 'Pardon my friend, he isn't NULL terminated'.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top