Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Opinions for best way to check a string for invalid Char
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Autre
Divers
Thread ID:
00189473
Message ID:
00189504
Vues:
9
>I need to check if there are characters outside of a list of valid characters. For example A-Z,a-z,0-9, are valid characters, how can I tell if an address has a value outside of these. I know I'm going to be using ASCII values, but what's the best way to search through the string? I use your method a lot myself when I know what I'm looking for. In this case it could be a rather large set of invalid characters, so I don't think it would be the best choice here.

Just a suggestion...
Call this ValAddrStr from txtAddress.Valid.
FUNCTION ValAddrStr
LPARAMETER lcAddrStr
LOCAL llRetValue
llRetValue = .T.
* May want to check for invalid parameter here, e.g. not a string.
FOR lnI = 1 TO LEN(m.lcAddrStr)
	IF NOT ( BETWEEN( SUBSTR(m.lcAddrStr, m.lnI, 1), 'A', 'Z' ) ;
			OR BETWEEN( SUBSTR(m.lcAddrStr, m.lnI, 1), 'a', 'z' ) ;
			OR BETWEEN( SUBSTR(m.lcAddrStr, m.lnI, 1), '0', '9' )
		llRetValue = .F.
		* Maybe give MESSAGEBOX() here.
		EXIT	&& The FOR loop
	ENDIF
ENDFOR
RETURN m.llRetValue
HTH,
Rich.
Rich Addison, Micro Vane, Inc., Kalamazoo, MI
Relax, don't worry, have a homebrew.
- Charlie Papazian, The New Complete Joy of Home Brewing
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform