#### Howdy, Stranger!

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

# Whole number function

Member Posts: 12
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]

• Member Posts: 85
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
• USAMember Posts: 4,624 ✭✭

_ \ http://forcoder.org \ free ebooks and video tutorials about ( Scratch, PHP, Visual Basic .NET, Delphi, C, Swift, Visual Basic, Ruby, Python, Objective-C, MATLAB, PL/SQL, Assembly, Java, R, C++, Go, C#, JavaScript, Perl Lua, ML, FoxPro, Ada, Fortran, Scheme, Crystal, SAS, LabVIEW, Clojure, Alice, Awk, Rust, Kotlin, Logo, Transact-SQL, COBOL, Prolog, Dart, Julia, Apex, Scala, Lisp, D, F#, ABAP, VBScript, Erlang, Hack, Bash ) __