IsNumber function?

Meeting place for R&R customers and clients to share tips and ideas. Post your questions, messages or problems here.
Post Reply
jmiskey
Posts: 46
Joined: Tue Oct 10, 2017 12:44 pm

IsNumber function?

Post by jmiskey » Tue Jun 07, 2005 12:31 pm

I see that there is an ISALPHA function available, but is there something like an ISNUMBER or ISNUMERIC function also?____I need to verify that a certain entry contains only numeric values.____Thanks.

kfleming
Posts: 5795
Joined: Tue Oct 10, 2017 12:44 pm

=> RE: IsNumber function?

Post by kfleming » Thu Jun 09, 2005 12:31 pm

The VAL() function will take you part of the way. It turns a string into a number so that "10AAA" would become the numeric 10. You would need to do some additional calculation to throw out a "10AAA" as a bad guy and keep "10.111" as a good guy. You could probably check the length of the string and the length of the VAL() converted back to a string to see if they are different so that the two characters for the 10 being less that the 5 characters in the original string would indicate an error. But start with VAL().____Kathleen__R&R Support

jmiskey
Posts: 46
Joined: Tue Oct 10, 2017 12:44 pm

==> RE: IsNumber function?

Post by jmiskey » Thu Jun 09, 2005 2:04 pm

I don^t think that will work.____Essentially, we have a test string that requires that the entries in spaces 6-11 all be numeric. I am trying to write code to verify that only numbers reside in these spaces. So, I am checking for any non-numeric values (i.e. letters, spaces, symbols, etc.)

kfleming
Posts: 5795
Joined: Tue Oct 10, 2017 12:44 pm

===> RE: IsNumber function?

Post by kfleming » Thu Jun 09, 2005 11:34 pm

Then you can use the VAL() function on even the INLIST function along with the SUBS() function if you want to test particular characters within the field.____For example:__IIF(INLIST(SUBS(myfield,6,1),^0^,^1^,^2^,^3^,^4^,^5^,^6^,^7^,^8^,^9^)=0,"The 6th character IS NOT a number","6th is indeed numeric")____Kathleen__R&R Support

jmiskey
Posts: 46
Joined: Tue Oct 10, 2017 12:44 pm

====> RE: IsNumber function?

Post by jmiskey » Fri Jun 10, 2005 7:51 am

I have ten characters I need to check (spaces 6-10 and spaces 12-16). So in order to use this method, I would need to write 10 equations, one to check each space?____I was hoping for an easier/more efficient way, like just checking the 2 sequences in whole (6-10 and then 12-16) to see if the values as a whole are valid numbers.

kfleming
Posts: 5795
Joined: Tue Oct 10, 2017 12:44 pm

=====> RE: IsNumber function?

Post by kfleming » Fri Jun 10, 2005 8:08 am

You could probably create a recursive function to do this. Have a look at the article http://www.livewarepub.com/ftp/TechDocs/Recursive_Functions.pdf for some examples of recursive functions.______Kathleen__R&R Support

Post Reply