Check if number is integer in Access

3

How to check if a number is integer in Access VBA?

I've tried

If Int(Me.Numero) Then
    Msgbox "É inteiro"
End If

But it did not work.

I wanted it if I type 8,5 it would return "Not integer".

The field is Not Coupled.

    
asked by anonymous 23.01.2014 / 17:55

3 answers

6

The function int( ) returns the integer part of the number. For example,

   
intNumber = Int(902.3)

would make the intNumber variable equal to 902.

In your case, just test if the number is equal to the integer of it. That is:

   
If Me.Numero = Int(Me.Numero) Then
    blablabla
Else
    bla2bla2bla2
End If
    
23.01.2014 / 18:07
1

According to this link , to check if the variable type is int / integer, use this code

   
If TypeName(x) = "Integer" Then
    
23.01.2014 / 18:07
0

Use the expression below, the function val returns only the integer part of the number, then just compare the number using the function against itself:

if val([valor]) = [valor] then 
    msgbox "Inteiro"
else

end if
    
30.01.2014 / 17:14