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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Format Text to Number

Status
Not open for further replies.

holgar

Technical User
Oct 29, 2003
14
DK
Hi,
I have a table(imported)with numbers like
28210.933 and .371.
What I want is 28.210,933 and 0,371.
I have tried xpr1: CDbl(CLng([aa]*100)/100) and it works fine with the first number but I get error on .0371.

Thanks
 
you get the error because it doesn't know which decimal point is correct. The one before 371 or the one after. You could check if the last charecter is a decimal point, and if so remove that charecter and then get the value. e.g temp: IIf(Right([field],1)=".",Left([field],Len([field]-1)),[field]) should remove last charecter if it is a decimal point.

[pc]

Graham
 
Val works
Thanks to both of you
 
Ooops. Here is another unexpected problem.
Again imported table (I can't do anything about it) with
a column where numbers are like 00000043,580000 and
0.8962. Val function doesn't work on both numbers neither other formatting does.
If it could help numbers are related to a column.Decimal numbers are related to DKK (currency) and the others to USD.

Thanks
 
What should the numbers be? 00000043,580000 doesn't look like a number at all. If they are numbers in the source I wonder if they are being imported incorrectly. Maybe you could look at the source of the data and import using a different delimiter or even fixed width.
 
My option will deal with the second problem, but how is the first problem to be dealt with? is the number 43 or 580000 or 43.58? or something else.

[pc]

Graham
 
You are right. It is badly imported, but you now, it is sometimes easier to find workaround then to grip the real problem.

00000043,580000 is in real 43,58 and 0.8962 is 0,8962
because i'm from Europe (comma as decimal).

Fortunatly I've build this code to tacle the problem:
1 variant:
STANDARDCOSTPRICE: Val(Replace([STANDARD_COST_PRICE];",";"."))

2 variant:
STANDARDCOSTPRICE: CDbl(Replace([STANDARD_COST_PRICE];".";","))

Thanks for trying to help

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top