搜索文章:

首页  |  Java技术  |  Asp.net  |  Asp编程  |  VC/C++  |  Delphi  |  VB编程

检测整数和长整数的函数

经常见到cint和clng的溢出出错,如果有检测函数就不会出这个问题,下面这两个函数是应朋友要求写的,看一下吧

检测字符串是否是整数
function is_int(a_str)
   if not isnumeric(a_str) or len(str) > 5 then
      is_int = false
      exit function
   elseif len(str) < 5 then
      is_int = true
      exit function
   end if   
   if cint(left(a_str , 4)) > 3276 then
      is_int = false
      exit function
   elseif cint(left(a_str , 4)) = 3276 and cint(right(a_str , 1)) > 7 then
      is_int = false
      exit function
   else
      is_int = true
      exit function
   end if   
end function

检测是否是长整数
function is_lng(a_str)
   if not isnumeric(a_str) or len(str) > 10 then
      is_lng = false
      exit function
   elseif len(str) < 10 then
      is_lng = true
      exit function
   end if   
   if clng(left(a_str , 9)) > 214748367 then
      is_lng = false
      exit function
   elseif clng(left(a_str , 9)) = 214748367 and clng(right(a_str , 1)) > 7 then
      is_lng = false
      exit function
   else
      is_lng = true
      exit function
   end if   
end function

()

相关文章:
© 2006   www.java-asp.net