isInteger?

1. Junior Member
Join Date
Dec 1969
Posts
26

isInteger?

is there a built in property in VBscript that will evaluate whether or not a number is an integer (i.e. whole number with no decimal)?<BR><BR>I know a function for this can be easily written - just wondering if it exists.

2. Senior Member
Join Date
Dec 1969
Posts
896

RE: isInteger?

Only isNumeric - which will catch decimals which isn&#039;t good.. i think you might have to write a function.

3. Senior Member
Join Date
Dec 1969
Posts
107

RE: isInteger?

no built in but...<BR><BR>(intX mod 1 = 0)

4. Senior Member
Join Date
Dec 1969
Posts
2,809

Clever!

Amazed I haven&#039;t seen that before...

5. Senior Member
Join Date
Dec 1969
Posts
10,852

Huh? That won't work.

3.2 mod 1 = 0<BR><BR>3 Mod 1 = 0<BR><BR>*Anything* Mod 1 = 0, so what will that tell you?

6. Senior Member
Join Date
Dec 1969
Posts
2,809

Huh...

Sum*****, 1 divides evenly into everything doesn&#039;t it...duh.

7. Senior Member
Join Date
Dec 1969
Posts
11,334

Couldn't you just do

If TypeName(x) = "Integer" Then<BR>...<BR><BR><BR>Should return "Single/Double" for floating numbers... May have to add an OR clause if you wanna test for type Long.

8. Senior Member
Join Date
Dec 1969
Posts
2,809

RE: Huh...

How about <BR>If instr(number,".") = 0 Then<BR> &#039;no decimal place, must be an integer<BR>Else<BR> &#039;There&#039;s a decimal place<BR>End If<BR><BR>Cloogey as hell...but it should work.

9. Senior Member
Join Date
Dec 1969
Posts
107

doh....

But there&#039;s go to be a single mathmatical expression to use<BR>

10. Senior Member
Join Date
Dec 1969
Posts
2,437

if x = cint(x) then <eom>

.

Posting Permissions

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