Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Check if only numbers in field
Message
From
13/03/2010 08:09:16
Hilmar Zonneveld
Independent Consultant
Cochabamba, Bolivia
 
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Environment versions
Visual FoxPro:
VFP 9 SP2
OS:
Vista
Network:
Windows XP
Database:
Visual FoxPro
Application:
Desktop
Miscellaneous
Thread ID:
01454194
Message ID:
01454289
Views:
77
This message has been marked as a message which has helped to the initial question of the thread.
>hi all,
>
>we have a field in an application that the cusotmer has started using for multiple things and they wish to continue using it that way. initially they may enter some text (20 char field) like COVER COONFIRMED but later they want to enter a PO number that they must supply to their customer to get paid. this PO number if abotu 10 chars long and is comprised of just numbers. they want to ensure that i don't allow them to create an invoice without their being only numbers in this field. I was thinking about going through every character in the field to make sure it is numeric, is there an easier way of doing this?

Don't forget that a character field will be padded with blanks. In this case, I believe Nadya's solution (using empty() function after the replacement) will work, Vladimir's solution (using len() after the replacement) won't. You may also want to check that there are no spaces BETWEEN digits; I therefore suggest the following alternative:
llValidData = len(chrtran(alltrim(MyField), "0123456789", "") = 0
The above will still accept spaces at the beginning of the field; if you want to reject those too, use trim() instead of alltrim().
Difference in opinions hath cost many millions of lives: for instance, whether flesh be bread, or bread be flesh; whether whistling be a vice or a virtue; whether it be better to kiss a post, or throw it into the fire... (from Gulliver's Travels)
Previous
Reply
Map
View

Click here to load this message in the networking platform