Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Determine if char field in a table is a number
Message
From
28/06/2009 23:50:01
 
 
To
28/06/2009 23:31:35
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
01408688
Message ID:
01408989
Views:
58
am curious.

In which case does
'N' = Type(myField)
fail?



>>>Hello All,
>>>
>>>How determine if a char field in a table contains a number ?
>>>
>>>
>>>Thanks
>>
>>CLEAR
>>CREATE CURSOR crsTest (myField Char(15))
>>INSERT INTO crsTest VALUES([3.50])
>>INSERT INTO crsTest VALUES([-4])
>>INSERT INTO crsTest VALUES([a3.50])
>>INSERT INTO crsTest VALUES([3a.50])
>>INSERT INTO crsTest VALUES([5433.123])
>>INSERT INTO crsTest VALUES([12345.6789])
>>INSERT INTO crsTest VALUES([12.50a])
>>
>>SCAN
>>    ? myField , IIF(ALLTRIM(STR(VAL(myField),15,5)) = ALLTRIM(myField),[ is Number],[ not number])
>>ENDSCAN
>>
>
>This test (wrongly) returns .F. if the input string has a leading "0" ...
>
>-m.
Jim Nelson
Newbury Park, CA
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform