检测整数和长整数的函数

2016-01-29 18:14 2 1 收藏

检测整数和长整数的函数,检测整数和长整数的函数

【 tulaoshi.com - ASP 】

  经常见到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

 

来源:https://www.tulaoshi.com/n/20160129/1505002.html

延伸阅读
标签: 电脑入门
在我们分区的时候,相信大家都是按照 1GB = 1024MB 这个标准公式来算的。但是实际上,在分区时直接套用这个公式是不正确的。 当然,我们只需要套用下面这个公式,分区就可以完美分出整数数值了。 这里我们把要分区的整数GB设置为N,则正确的计算公式应为: (N-1)*4+1024*N 根据此公式算得的结果单位为MB。 例如,你想要得到一个2GB的分区...
using System.Text; private string AddNumber(string numA, string numB) { int lenA=0, lenB=0; int lenI=0, intTen=0; int intA=0, intB=0; StringBuilder result=new StringBuilder(""); lenA=numA.Length; lenB=numB.Length; if(lenA>lenB) lenI=lenA; else lenI=lenB; for(int i=0; i { if(i intA=Convert.ToInt16(nu...
标签: PS基础 PS抠图
  PS入门教程6-7:实战调整数码照片 调整数码照片的目的是为了在拍摄不足的前提下做些弥补,追求的是接近真实的画面效果。 现在我们来讲解一些用曲线来调整数码照片的实例。开始前先复习一下曲线和直方图中色阶的内容。 在曲线调整中,按照数学平面坐标系来看,向下移动可以看作是Y轴方向的减少,向上移动可以看作是Y轴方向增...
核心思想是 当n为偶数时,a^n = a^n/2 × a^n/2 当n为奇数时,a^n = a^(n-1)/2 × a^(n-1)/2  × a 代码如下: 代码如下: public class Power {  public static void main(String[] args) {   System.out.println(power(5.5,5));  }  private static double power(double base, int exponent) {   ...
标签: excel
如何运用Excel将整数转变为年月日形式   具体操作过程如下: ①我先打开之前准备好的教程课件,便于大家学习,下面要进行讲解的就是利用函数功能快速完成领导布置的任务。 ②单击B5单元格,输入下列函数公式:=INT(A5/365)&"年"&INT((MOD(A5,365))/30)&"月"&MOD(MOD(A5,365),30)&am...

经验教程

252

收藏

26
微博分享 QQ分享 QQ空间 手机页面 收藏网站 回到头部