Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Leading zero insertion?
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00315933
Message ID:
00315941
Vues:
18
>Can I condense this code where I am inserting leading zeroes?
>It's not easy to read and it's also hard to follow. All it does is insert leading zeroes so I can do a seek.
>
>IF VALU $ "0123456789"
> DO CASE
> CASE VAL(VALU) < 10
> SEEKIT = "0000000" + UPPER(ALLTRIM(THISFORM.t_ln.VALUE))
> CASE VAL(VALU) < 100 AND VAL(VALU) > 9
> SEEKIT = "000000" + UPPER(ALLTRIM(THISFORM.t_ln.VALUE))
> CASE VAL(VALU) < 1000 AND VAL(VALU) > 99
> SEEKIT = "00000" + UPPER(ALLTRIM(THISFORM.t_ln.VALUE))
> CASE VAL(VALU) < 10000 AND VAL(VALU) > 999
> SEEKIT = "0000" + UPPER(ALLTRIM(THISFORM.t_ln.VALUE))
> CASE VAL(VALU) < 100000 AND VAL(VALU) > 9999
> SEEKIT = "000" + UPPER(ALLTRIM(THISFORM.t_ln.VALUE))
> CASE VAL(VALU) < 1000000 AND VAL(VALU) > 99999
> SEEKIT = "00" + UPPER(ALLTRIM(THISFORM.t_ln.VALUE))
> CASE VAL(VALU) < 10000000 AND VAL(VALU) > 999999
> SEEKIT = "0" + UPPER(ALLTRIM(THISFORM.t_ln.VALUE))
> CASE VAL(VALU) < 100000000 AND VAL(VALU) > 9999999
> SEEKIT = UPPER(ALLTRIM(THISFORM.t_ln.VALUE))
> ENDCASE
>ENDIF
>
>Thanks in advance.

How about RIGHT(REPL('0',8)+ UPPER(ALLTRIM(thisform.t_ln.value),8)

or PADL(UPPER(ALLTRIM(thisform.t_ln.value)),8,'0')
EMail: EdR@edrauh.com
"See, the sun is going down..."
"No, the horizon is moving up!"
- Firesign Theater


NT and Win2K FAQ .. cWashington WSH/ADSI/WMI site
MS WSH site ........... WSH FAQ Site
Wrox Press .............. Win32 Scripting Journal
eSolutions Services, LLC

The Surgeon General has determined that prolonged exposure to the Windows Script Host may be addictive to laboratory mice and codemonkeys
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform