5
How to check if a number is integer in Access VBA?
I tried to
If Int(Me.Numero) Then
Msgbox "É inteiro"
End If
But it didn’t work.
I wanted if I typed 8.5 it returned "It’s not whole".
The field is Unattached.
5
How to check if a number is integer in Access VBA?
I tried to
If Int(Me.Numero) Then
Msgbox "É inteiro"
End If
But it didn’t work.
I wanted if I typed 8.5 it returned "It’s not whole".
The field is Unattached.
7
The function int( )
returns the whole part of the number. For example,
intNumber = Int(902.3)
would cause the intNumber variable to equal 902.
In your case, just test if the number is equal to its integer. That is:
If Me.Numero = Int(Me.Numero) Then
blablabla
Else
bla2bla2bla2
End If
'Cause I didn’t think of it before, thanks guys.
1
According to this link, to check if the variable type is int/integer, use this code
If TypeName(x) = "Integer" Then
0
Use the expression below, the function val
returns only the whole part of the number, then just compare the number using the function against itself:
if val([valor]) = [valor] then
msgbox "Inteiro"
else
end if
Browser other questions tagged ms-access vba
You are not signed in. Login or sign up in order to post.
Describe better what is 'not working', error? result not expected?
– rray