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)