Discover if a number is an integer

# Thread: Discover if a number is an integer

1. Senior Member
Join Date
Dec 1969
Posts
111

## Discover if a number is an integer

This is a really simplified version of what I am trying to do. The problem with this is the &#039;Mod&#039; fuction converts both numbers to integers before doing its math. Basically I&#039;m trying to find out if my variable divided by ten is an integer or not. Is there an easy/pretty way to do this, or do I have to search for a decimal place in the number to figure it out?<BR>&#060;%<BR>intNumber = 72<BR>If (intNumber / 10) Mod 1 = 0 Then<BR> blah = True<BR>Else<BR> blah = False<BR>End If<BR>%&#062;

2. Senior Member
Join Date
Dec 1969
Location
Los Angeles, CA
Posts
21,192

## Easy

intNumber = 72/10<BR>If intNumber = cint(intNumber) then<BR>&#039;it is an int<BR>blah = True<BR>Else<BR>blah = False<BR>End If<BR>

3. Senior Member
Join Date
Dec 1969
Posts
96,118

## Ummm...that's a mistake...

If you use CINT, then you can only handle numbers from -32768 to +32767.<BR><BR>Use INT() instead. Then you can handle any number up to about 14 digits.<BR><BR>Also, it&#039;s kind of silly to code<BR> If num = Int(num) Then<BR> blah = True<BR> Else<BR> blah = False<BR> End If<BR><BR>Why not simply code:<BR> blah = ( num = INT(num) )<BR><BR>Does the same thing in one statement.<BR><BR>

4. Senior Member
Join Date
Dec 1969
Posts
111

## RE: Discover if a number is an integer

After much thought and pondering I have realized that I am most definatley a moron. Nevermind this post. Figured it out on my own. &#060;sheepish grin&#062;.

5. Senior Member
Join Date
Dec 1969
Location
Los Angeles, CA
Posts
21,192

## Suuuure

after we give you the answer &#060;sneer&#062;<BR><BR>

#### Posting Permissions

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