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.
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.
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
According to this link , to check if the variable type is int / integer, use this code
If TypeName(x) = "Integer" Then
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