Click to See Complete Forum and Search --> : Testing for Integer Input


chem1
January 21st, 2000, 11:31 AM
Hello there!
I have developed a calculator program and now I want to check whether a user has entered an Intgere value(Without a decimal) so that the factorial of the value can be calculated.If the value contains decimal i-e it is not intger then an error can be raised.
I have tried the VarType function but to no avail
Please help,
Thnakx in advance
Kamra.

Aaron Young
January 21st, 2000, 01:48 PM
Try something like:

Function IsDecimal(byval dVal as Double) as Boolean
IsDecimal = (Int(dVal) <> dVal)
End Function



Usage: If IsDecimal(dMyValue) Then Msgbox "Can't Calculate Factorial"

Aaron Young
Analyst Programmer
ajyoung@pressenter.com
aarony@redwingsoftware.com