Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Bad numeric value reading Excel file
Message
From
02/06/2011 17:12:14
 
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Environment versions
Visual FoxPro:
VFP 9 SP2
OS:
Windows 7
Network:
Windows 2003 Server
Database:
Visual FoxPro
Miscellaneous
Thread ID:
01512647
Message ID:
01512650
Views:
53
>We update customer price lists from Excel spreadsheets. Over the years I have been able to read any of the values that might be in a cell but this one has me pulling my hair out.
>
>The part numbers are in a format of 999.999 Most of the time but sometimes 999.999ABC and sometimes 999.9999. The problem is that although the part number shows as 123.456 or 123.4567 in the cell, TRANSFORM() converts it to 123.45670000000. Any ideas on how to grab the number as it should be. I can't just trim the number as the length varies and sometimes does end in 00.

This sounds like a case where the "part number" should be a string, whether in the source it's a pure "number" or a string also containing alpha characters.

For those that are just digits + decimal point, you could use STR( ), which lets you specify total length and desired number of decimal points, and trim as desired e.g.
MyVal = LTRIM( STR( Number, 20, 4 ) )
Regards. Al

"Violence is the last refuge of the incompetent." -- Isaac Asimov
"Never let your sense of morals prevent you from doing what is right." -- Isaac Asimov

Neither a despot, nor a doormat, be

Every app wants to be a database app when it grows up
Previous
Reply
Map
View

Click here to load this message in the networking platform