CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Aug 1999
    Location
    Pakistan
    Posts
    366

    Testing for Integer Input

    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.


  2. #2
    Join Date
    Sep 1999
    Location
    Red Wing, MN USA
    Posts
    312

    Re: Testing for Integer Input

    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
    [email protected]
    [email protected]
    Aaron Young
    Senior Programmer Analyst (Red Wing Software)
    Certified AllExperts Expert

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured