Whole number function - Programmers Heaven

Howdy, Stranger!

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

Categories

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.