Posted By

Shurik76 on 07/16/10


Tagged


Versions (?)

IsInteger


 / Published in: ASP
 

  1. 'Option1
  2. If x = CInt(x) Then
  3. '...
  4.  
  5. 'Option2
  6. If TypeName(x) = "Integer" Then
  7. '...
  8.  
  9. 'Option3
  10. 'Relies on LCID=1033 eg. point (".") is a decimal delimiter instead of comma (","))
  11. If InStr(x,".") = 0
  12. 'OR
  13. If CBool(InStr(x,"."))
  14.  
  15. 'Option4
  16. Function isInteger (number)
  17. Dim result
  18. if(IsNumeric(number)) then
  19. if(InStr(number,".")=0) then
  20. result=true
  21. else
  22. result=False
  23. end if
  24. else
  25. result=False
  26. end if
  27. isInteger = result
  28. End Function
  29.  
  30. 'Option5
  31. Function IsInteger(byVal string)
  32. dim regExp, match, i, spec
  33. For i = 1 to Len( string )
  34. spec = Mid(string, i, 1)
  35. Set regExp = New RegExp
  36. regExp.Global = True
  37. regExp.IgnoreCase = True
  38. regExp.Pattern = "[0-9]"
  39. set match = regExp.Execute(spec)
  40. If match.count = 0 then
  41. IsInteger = False
  42. Exit Function
  43. End If
  44. Set regExp = Nothing
  45. Next
  46. IsInteger = True
  47. End Function

Report this snippet  

Comments

RSS Icon Subscribe to comments
Posted By: Vordreller on July 16, 2010

This looks more like VB.NET

You need to login to post a comment.