Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Sign In with Facebook Sign In with Google Sign In with OpenID

Categories

We have migrated to a new platform! Please note that you will need to reset your password to log in (your credentials are still in-tact though). Please contact lee@programmersheaven.com if you have questions.
Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

Whole number function

Mr. HawkMr. Hawk Posts: 12Member
i'm haveing a bit of trouble creating a whole number function that returns a true/false boolean variable. I've narrowed the problem down to what i believe is the math that the function contains. Or if there's an easier way of doing this i'd like to know it as well.

i've included the code that i have so far, mabye that'll help a bit:

[code]
Function PerfectSquare(intNumber) As Boolean
[b]intNumber = Sqr(intNumber)
intNumber = dblNumber Mod 1[/b] 'INCORRECT!! - I need to know what to put here so that 'intNumber'
'would equal a whole number or a decimal that would return 'FALSE'
If intNumber <> 0 Then
PerfectSquare = False
Else
PerfectSquare = True
End If
End Function
[/code]

Comments

  • GazzaladGazzalad Posts: 85Member
    This will tell you if its a whole number or not:

    Private Function flgWhole(dblInput As Double) As Boolean

    If dblInput = Int(dblInput) Then flgWhole = True

    End Function

    Is this what you meant?

    G
Sign In or Register to comment.