Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Value from string
Message
From
27/09/2007 12:27:42
 
 
To
27/09/2007 12:24:28
Joel Hokanson
Services Integration Group
Bellaire, Texas, United States
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Environment versions
Visual FoxPro:
VFP 9 SP1
OS:
Windows XP SP2
Network:
Windows 2000 Server
Database:
Visual FoxPro
Miscellaneous
Thread ID:
01257239
Message ID:
01257243
Views:
21
>When I import from a CSV file then try to convert a string to a value, it seems to round it off.
>
>use ar
>APPEND FROM ar.csv csv
>
>I have a field called balance and if it is a Char field, then the number imports fine
>I get 4,464.25 left justified
>
>If I use numeric or currency I get 4.00
>
>So I want to convert character 4,464.25 left justified to a number
>If I use Val(Balance) if get 4.00
>
>I would think it has to do with Rounding but I can not seem to make it work right???
>
>Thanks
>Joel in Houston

No, the problem is the "," (comma). VAL() stops at the first non-numeric character, only 0-9, sign (+/-) and decimal point are valid.

You'll have to import this in two steps, one as the character field with the comma, and then a second step that transfers the character field and translates the comma to nothing into a numeric field.
Fred
Microsoft Visual FoxPro MVP

foxcentral.net
Previous
Reply
Map
View

Click here to load this message in the networking platform