Information générale
Catégorie:
Codage, syntaxe et commandes
>>Using VFP6.0 SP3
>>
>>I'm tring to remove a space from a charter string exp("ABC 12345")
>>!ISDIGIT copies the space
>>ISDIGIT doen't copy the "ABC"
>>
>>TIA
>
>Looks like you've found a solution, but I wanted to offer up one of my favorite VFP string functions: CHRTRAN().
>
>YOu can use it to replace all characters in a stringthat match any character in another string with a third expression. In your particular case, you would just:
>
>lcString = CHRTRAN(lcString, " ","")
>
>But you can also do tons of other cool stuff, like remove any invalid characters:
>
>lcString = CHRTRAN(lcString, "~!@#$%^&*?","")
>
>Or getting even more creative, you can remove any character that does not
>occur in a given string, so you can filter your string for only valid characters. Say a product code is only supposed to contain the digits 0-9 and the letters A-F, and all other characters should be removed-
>
>lcString = CHRTRAN(lcString, CHRTRAN(lcString, "0123456789ABCDEF",""),"")
VERY clever, Erik.
Précédent
Répondre
Voir le fil de ce thread
Voir le fil de ce thread à partir de ce message seulement
Voir tous les messages de ce thread
Voir tous les messages de ce thread à partir de ce message seulement