Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

numberic field checking 3

Status
Not open for further replies.

philk12

Programmer
Dec 29, 2005
20
US
We are converting data files and we want to test invalid numeric data errors in our converted files. What is the best way to do so? Is there any scalar function that returns NULL if the content of a numeric field is invalid?

Thanks in advance for your help
 
philk12,

When you say "invalid" - what do you mean by that? Do you mean invalid by your own rules or invalid according to FoxPro?

If it is the first, then you'd have to write your own function to test for invalid numeric data errors.

If you mean according to FoxPro - I'm not sure what you mean. Can you give an example?

What do you mean by a scalar function?


Hope that helps,

Stewart
PS If you want to get the best response to a question, please check out FAQ184-2483 first.
 
philk2

There is a function in vfp called ISDIGIT
Also is there a function ISNULL

if you look at the help function of ISDIGIT
you will see it only look at the leftmost character of a string.

But this could be solved by making a loop of the character field

wfg,

FILIP
 
Filip,

OK, apparently you're talking about character data that needs to be limited to numbers. If that's correct, this will check the data for you. Let's assume you're dealing with a field called cNumber.
Code:
IF LEN(CHRTRAN(cNumber,'1234567890',"") > 0
   = MESSAGEBOX("Bad data ...")
ENDIF

Regards,
Jim
 
Yes that is very cool, Jimbo. Thank you all for your kind assistance. Philky
 
Philky,

Actually, I left off the final closing ) and the code probably wouldn't work against the field itself. You'd need to store the data to a variable and check the variable.

Regards,
Jim
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top