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!

ToNumber rounds instead of preserving decimal place

Status
Not open for further replies.

LMcK07

Technical User
Nov 6, 2007
3
US
I'm using CR XI Prof and hit a strange issue converting a string field to a number so I could calculate an average.

The string field "Lab.Value" has one or two characters (always digits), a decimal, and another character/digit - e.g., 7.3 or 10.8. Using both ToNumber and CDbl, the result rounded the value to no decimal places - 7.0 and 11.0. I made sure that formatting wasn't the problem - I could display any number of decimal places but it still gave me that whole number followed by however many 0's. Because I was in a hurry I got around the issue by converting the string to currency and then in a second formula converting the currency to number, and everything appeared to work out fine.

But why is this happening, and how can I prevent it in the future? Thanks so much for y'all's help.

Laura
 
Right click on the new number->format field->number->customize and make sure decimal is set to 1.0 and that rounding is set to .1 (for one decimal).

-LB
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top