Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Calculate any decimal points
Message
From
29/04/2003 11:14:49
Hilmar Zonneveld
Independent Consultant
Cochabamba, Bolivia
 
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00782716
Message ID:
00782724
Views:
16
Supposedly, in VFP 6 or later, you can use trans(), but this produces impredictable behavior with some numbers.

You can also try padr() or padl(), in combination with alltrim(). I think it gives better results.
? alltrim(padr(5.3, 20))
? alltrim(padr(5.321, 20))
If you are not satisfied with the results, you will have to write your own UDF.

>Hi Everybody,
>
>I want to calculate the numeric value of a string with any decimal points. The problem with Val() is: I have to use Set Decimal To for a specific number of decimal points.
>
>For example.
>If Set Decimal to 2
>Val(“89.335”) yields 8.34
>and if Set Decimal to 2
>Val((“89.335”) yields 8.335
>
>Is there any solution?
>
>Thanks,
>Ali
Difference in opinions hath cost many millions of lives: for instance, whether flesh be bread, or bread be flesh; whether whistling be a vice or a virtue; whether it be better to kiss a post, or throw it into the fire... (from Gulliver's Travels)
Previous
Reply
Map
View

Click here to load this message in the networking platform