Check if Text is Integer

  • Thread starter Thread starter Ripan
  • Start date Start date
R

Ripan

I am designing forms to input data of various types. I want to be abl
to check if an input into a text box is an integer. I know th
IsNumeric will accept any number (including floats), but I just wan
integers without any other punctuation. Is there a function to do thi
or will it have to be done manually (i.e. Check every character).


Thanks for any help
 
Ripan,

From a previous post by Tom Ogilvy....

? isnumeric("88")
True
? application.IsNumber("88")
False

isnumeric tests if the value can be interpreted as a number. the
worksheetfunction, isnumber tests if it is being stored as a number.

Will this help??

John
 
Jon,

Thanks, but I want to be able to only screen for integers, and not
floats. So "123" is acceptable but not "12.5" or "123,456".

Ripan
 
Can you incorporate the MOD() function? MOD returns the remainder that
results when a number is divided by another. For instance,
MOD(7,3) = 1, because 7 / 3 = 2 with 1 remaining.

If the result of MOD(x,1)=0 then x is an integer. Does that do it for you?
 
This is true, but MOD requires two integer inputs as it is not defined
for floating numbers (e.g. 123.5 Mod 1 is undefined). VBA will most
likely implicitly cast the floating point number to an integer (e.g.
123.5 to 123) and perform the operation.

Doesn't look like this will work. currently, I just go through each
individual character in the number and check if it is a digit. So far I
can't come up with a better way.

Thanks.
 
Back
Top