vba check if variable is whole number

The solution for “vba check if variable is whole number” can be found here. The following code will assist you in solving the problem.

‘Two different ways to check if a double is assigned a whole number:

Function IsWholeNumber(n#) As Boolean
IsWholeNumber = 0 = InStr(n, “.”)
End Function

Function IsWholeNumber(n#) As Boolean
IsWholeNumber = n = Int(n)
End Function

————————————————————-

MsgBox IsWholeNumber(123) ‘<---displays: True MsgBox IsWholeNumber(123.001) '<---displays: False

Thank you for using DeclareCode; We hope you were able to resolve the issue.

More questions on [categories-list]

Similar Posts