optom
09-11-2003, 06:35 AM
is there a way I can confirm if a number is an integer or not. I will be generating random number (eg 0 to 30) and dividing this by 3 (for example). Is there a way I can tell if my final product is an integer or not? A nice idea would be " if x is integer then ..."
Thanks
Optom
gundavarapu
09-11-2003, 06:39 AM
try this...
msgbox isnumeric(1234) 'displays true
msgbox isnumeric("noway") 'displays false
hope this helps!
wildfire1982
09-11-2003, 06:41 AM
do you mean like this:
if Int(variable) =Variable
this will compare the variable to the integer equivalent. Or do you mean you want to know what the variable type has been declared as?
SpaceFrog
09-11-2003, 06:42 AM
you can always test if cint(myvar) = myvar this would mean it is an integer ...
function isinteger(Myvar as single) as boolean
if cint(myvar) = myvar then
isinteger = true
else
isinteger = false
end function
optom
09-11-2003, 07:10 AM
Thanks spacefrog
That worked a treat.
Optom
you can always test if cint(myvar) = myvar this would mean it is an integer ...
function isinteger(Myvar as single) as boolean
if cint(myvar) = myvar then
isinteger = true
else
isinteger = false
end function