Difference between revisions of "Is it an integer"

From HashVB
Jump to: navigation, search
Line 8: Line 8:
  
 
Simple as that.
 
Simple as that.
 
<b>NOTE: </b>This will only work when using the class from within the same project in VB.  If compiled and used as a COM component, then any methods declared as 'Friend' will not appear.  See MSDN on the topic of the Friend keyword: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vbenlr98/html/vakeyFriend.asp
 

Revision as of 20:54, 1 September 2005

So, you want to tell if a number is an integer?

VB has a very useful function called Int() that will give you the integer portion of a number. You can then compare this to the original, and if they match, it is an integer.

Function IsInteger(byval Value) as Boolean
  IsInteger = (Int(Value) = Value)
End Function

Simple as that.