Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Transform(x,?????)
Message
De
06/01/2005 19:20:29
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Versions des environnements
Visual FoxPro:
VFP 7 SP1
OS:
Windows XP SP2
Network:
Windows XP
Database:
Visual FoxPro
Divers
Thread ID:
00974835
Message ID:
00974912
Vues:
42
This message has been marked as the solution to the initial question of the thread.
>Hi guys...
>
>I have a field NUMERIC N (12,6) and this field is populate with some values. Example:
>
>
>  12.210000
> 145.245000
>1524.352000
>  1.3562400
> 15.2546423
>
>
>Ok... no problem here... but I have to print these numbers like that:
>
>
>  12.21000 ->   12.21
> 145.24500 ->  145.245
>  54.00000 ->   54.00
>1524.35200 -> 1524.352
>  1.356240 ->    1.35624
> 15.254642 ->   15.254642
>
>
>I'm using ??? Tran(MyField,"??????????") to print this report... and I have to print, at least, two decimals... but if the number has more than two decimals, I have to print them, until completed six positions.
>
>Any idea to change ??????? for a solution? :-)
>
>TIA!

try this:
? formatNumber(12.210010,12,6,2)
? formatNumber(145.00,12,6,2)
? formatNumber(145.003,12,6,3)
? formatNumber(145.000,12,6,3)
? formatNumber(145.123456,12,6,3)

FUNCTION formatNumber(nValue,iMaxLen,iMaxDec,iMinDec)
* iMaxLen>=iMaxDec+2 ; iMaxDec>=iMinDec>=0
RETURN LEFT(STR(m.nValue,m.iMaxLen,m.iMaxDec),m.iMaxLen-m.iMaxDec+m.iMinDec);
+CHRTRAN(RTRIM(CHRTRAN(RIGHT(STR(m.nValue,m.iMaxLen,m.iMaxDec),m.iMaxDec-m.iMinDec),"0"," "))," ","0")
Fabio
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform