Mark ---
How will you know which should be all digits and which should be all characters? Oh well, assuming you have logic to determine that, the following works:
cType ="C"
cString=UPPER(table.field)
lValid=.T.
FOR i = 1 TO LEN(ALLT(cString))
IF cType="C" AND (VAL(SUBS(cString(i,1))#0 OR SUBS(cString,i,1)="0")
lValid=.F.
EXIT
ENDIF
IF cType="N" AND (VAL(SUBS(cString(i,1))=0 AND SUBS(cString(i,1))#"0")
lValid=.F.
EXIT
ENDIF
ENDFOR
IF lValid comes out false, it's not valid.
>I have following requirement
>
>I have one database field whose contents are either all letters are all digits. how could i check this validaion. Please help.
>
>i.e.
>example 1
>
>lcString = 'ABCD'
>
>this is valid string because all characters are lettes. but if it is 'ABC1' then it is not valid because 1 inside string is not letter.
>
>example 2
>
>lcString = '1234'
>
>this is valid string because all characters are digits. but if it is
>'12a4' then it is not valid because 'a' inside string is not digit.
>
>I have checked IsAlpha() and IsDigit() functions but i don't think they will be useful here. Please help me how could i check above validation and ensure that it is valid string.
>
>Thanks for your help in advance.
>Mark
------------------------------------------------
John Koziol, ex-MVP, ex-MS, ex-FoxTeam. Just call me "X"
"When the going gets weird, the weird turn pro" - Hunter Thompson (Gonzo) RIP 2/19/05