精美而实用的网站,关注web编程技术、网站运营、SEO推广,让您轻松愉快的学习

ASP数据类型判断检测——整数校验函数,判断传入的字符串是否是整型字符,通过循环逐一判断每个字符,精确判断并返回true或false。函数代码:

ASP整数校验函数

Public function isInteger(para)
     on error resume Next
     Dim str
     Dim l,i
     If isNUll(para) then 
     isInteger=false
     exit function
     End if
     str=cstr(para)
     If trim(str)="" then
     isInteger=false
     exit function
     End if
     l=len(str)
     For i=1 to l
      If mid(str,i,1)>"9" or mid(str,i,1)<"0" then
      isInteger=false 
      exit function
      End if
     Next
     isInteger=true
     If err.number<>0 then err.clear
 End Function

判断数字是否为整数,可用于参数合法性判断。

Tags:ASP 整数 函数