Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Calculate any decimal points
Message
De
29/04/2003 11:14:49
Hilmar Zonneveld
Independent Consultant
Cochabamba, Bolivie
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00782716
Message ID:
00782724
Vues:
15
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)
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform