Check if integer

Pauldohert

Something in here
Local time
Today, 15:04
Joined
Apr 6, 2004
Messages
2,101
What the easiest way to turn text to an integer - ir have vaiable defined as long and an inputbox - want to keep asking for an input until I get an integer.

Have IsNumeric - can this be applied to int.

Or could I use localised error handling?

Thanks
 
Search the Access VBA help files for the VarType Function.
 
Thanks thats exactly what I want - is there a way of finding these functions if I don't know already that they exist?

Paul
 
I just searched for IsNumeric since you mentioned it for I knew there was something out there, I just did not know what it was called. There is a ton of stuff in the built-in Access VBA help files, you just have to poke around it.
 
On closer inspection of the vartype - it tells me what data type my input return is - it always returns string. What I need to know is can I convert the sring to int.

Could just try and use an error handler if not succesful.

How could I use an error handler just around this line - rather than use it generically at the end of the procedure, just in case I handler the error somewhere I didn't intend to.

Hope I am making sense.
 
want to keep asking for an input until I get an integer.
does that mean that if it is a decimal you want to ask again, just round off or truncate?

Peter
 
That means if its a decimal I want to ask again, the input always should be an integer, anything else is not allowed.

Cint(56.2) comes out at 56.

Really though I want them to enter 56 as only an int is acceptable and I would be interpreting an invalid entry, possibly incorectly if I used CInt - ie could be 562?.

I suppose I could just check for the point, or is there a remainder function I could use.
 
Last edited:
If Int(Val(Me.txtBox)) <> Val(Me.txtBox) Then
'-- There is a decimal
End If
 

Users who are viewing this thread

Back
Top Bottom