Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How to check this validaion?
Message
From
08/07/1999 00:30:45
 
 
To
07/07/1999 18:43:58
General information
Forum:
Visual FoxPro
Category:
Other
Miscellaneous
Thread ID:
00238591
Message ID:
00238683
Views:
6
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"   && or "N" for numeric
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
Previous
Reply
Map
View

Click here to load this message in the networking platform