The CInt function can handle only integer values.
So the following could test if a number is in an integer range:
If CInt(Text1.text)=CInt(Text1.Text) Then
'is integer
end if
The above if statement will either pass as true or generate an error. This if statment will never return false. CInt, CCur, CStr are all casting functions that will not accept anything out of it's range. Therefore by simply calling the statement you can determine if it is an integer.
Consider the statment you wrote:
IsInteger=(CInt(Valor) = Valor)
This statment will return the same result as
IsInteger=(CInt(Valor) = CInt(Valor))
because VB is doing the type casting (conversion) in the first one. Try IT!! You have to think like a computer.They both will require error trapping however.
You cannot write CInt(32768) without generating an overflow error. So if any value in your text box is out of the integer range, an error will generate.
You could also do:
IsInteger=Val(Valor)>=-32767 and Val(Valor)<=32767
That would require minimal error trapping.
CInt(13.33) = 13, integers are not floating point numbers. The numbers are rounded. If you want to disallow 13.33 as a valid integer in your program then you would do a statement like this:
IsInteger=(CInt(Valor) = Valor) and (Int(Valor)=Valor)
That should help, unless I'm just missing the point of your question. :->