天枫常用的ASP函数封装如下

2019-01-13 12:34:05王振洲

    '****************************************************
 '函数名:isInteger
 '作  用:整数检验
 '参  数:tstr ----字符
 '返回值:true是整数,false不是整数
 '****************************************************
 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

    '****************************************************
 '函数名:CheckName
 '作  用:名字字符检验 
 '参  数:str ----字符串
 '返回值:true无误,false有误
 '****************************************************
 Public Function CheckName(Str)
  Checkname=true
  Dim Rep,pass
  Set Rep=New RegExp
  Rep.Global=True
  Rep.IgnoreCase=True
  '匹配字母、数字、下划线、汉字且必须以字母或下划线或汉字开始
  Rep.Pattern="^[a-zA-Z_u4e00-u9fa5][wu4e00-u9fa5]+$"
  Set pass=Rep.Execute(Str)
  If pass.count=0 Then CheckName=false
  Set Rep=Nothing
 End Function

 '****************************************************
 '函数名:CheckPassword
 '作  用:密码检验
 '参  数:str ----字符串
 '返回值:true无误,false有误
 '****************************************************
 Public Function CheckPassword(Str)
  Dim pass
  CheckPassword=true
  If Str <> "" Then
   Dim Rep
   Set Rep = New RegExp
   Rep.Global = True
   Rep.IgnoreCase = True
   '匹配字母、数字、下划线、点号
   Rep.Pattern="[a-zA-Z0-9_.]+$"
   Pass=rep.Test(Str)
   Set Rep=nothing
   If not Pass Then CheckPassword=false
   End If
 End Function