Several ways:
If (x MOD 2) = 1 Then
' x is odd
Else
' x is even
End If
Assuming x is an INT or LONG value, you could also do
If (x AND 1) = 1 Then
' x is odd
Else
' x is even
End If
You could assure that x is integral by applying CLNG() function.
If (CLNG(x) AND 1) = 1 Then
There are other ways, but those are the most efficient.
|