Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Check a String for non-numeric Characters
Message
De
15/02/2001 08:43:11
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00476101
Message ID:
00476228
Vues:
28
Hi Barbara,

That is what I needed. Thanks for the help.

>How about a combination of strtran and chrtran?
>
>Use Chrtran to get rid of the numbers and decimals and spaces, then use Strtran to get rid of specific abbreviations. You will have to be sure that you remove "cm" before you remove "m", but you should end up with either an empty string (valid) or a string with an extra character (invalid).
>Function MyString()
>  lparameter cString
>  lRet = .t.
>  cNewStr = chrtran(cString, [1234567890 +-./'"], "")
>  cNewStr = strtran(cNewStr, 'cm', '')
>  cNewStr = strtran(cNewStr, 'mm', '')
>  cNewStr = strtran(cNewStr, 'm', '')
>  lRet = empty(cNewStr)
>return lRet
>This gives you a TRUE return if the string is valid. Note that I've included a space, +, -, ' and " in the chrtran() function. You may have other symbols to add also.
>
>HTH
>Barbara
>
>
>>If I have a character string that contains numbers and non-numbers how can I pull out the non-numbers to see if the string is valid for me?
>>
>>If the string was [12' 2 3/4" + 23' 2.45"] this is valid
>>if the string had a character in it except c and m for meter, centimeter and millimeter it is not valid....
>>
>>32cm + 23mm valid
>>12' 3 3/4c not valid
>>
>>
>>THanks
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform