校园春色亚洲色图_亚洲视频分类_中文字幕精品一区二区精品_麻豆一区区三区四区产品精品蜜桃

主頁 > 知識庫 > asp cint clng的范圍與防止cint和clng的溢出解決方法大全

asp cint clng的范圍與防止cint和clng的溢出解決方法大全

熱門標簽:電銷機器人采購 地圖標注還可以做嗎 高質量的電銷外呼系統 友邦互聯電銷機器人違法嗎 外呼系統怎么話費 無營業執照地圖標注教學 硅基電話機器人加盟 宿州防封外呼系統平臺 滴滴地圖標注上車點

首先我們需要了解的是

cint范圍 -32,768 到 32,767。
clng范圍 -2,147,483,648 到 2,147,483,647。

cint與clng含義:

都可以強制將一個表達式轉換成數據類型

cint與clng處理數據的范圍:

CInt Integer -32,768 至 32,767,小數部分四舍五入。
CLng Long -2,147,483,648 至 2,147,483,647,小數部分四舍五入。

所謂溢出指的是超出處理數據的范圍,下面代碼是處理數據防止溢出的代碼,大家可以自己看看:

'檢測是否是短整數

復制代碼 代碼如下:

sub Is_Int(string)
if len(abs(string))>10 then response.write "數據溢出":response.end
if instr(string,"-")1 then
if cint(left(string,4))>3276 and cint(right(string,1))>7 then response.write "數據溢出":response.end
else
if cint(left(abs(string),4))>3276 and cint(right(string,1))>8 then response.write "數據溢出":response.end
end if
end sub


'檢測是否是長整數
復制代碼 代碼如下:

sub Is_Lng(string)
if len(abs(string))>10 then response.write "數據溢出":response.end
if instr(string,"-")1 then
if clng(left(string,9))>214748364 and clng(right(string,1))>7 then response.write "數據溢出":response.end
else
if clng(left(abs(string),9))>21478364 and clng(right(string,1))>8 then response.write "數據溢出":response.end
end if
end sub


以下是一些檢驗函數,需要的朋友可以參考下:

第一種:
一、檢測它是不是整數 
復制代碼 代碼如下:

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  

如果我們只需要是數子,其它的東西,都可以替換為空,下面這個是腳本之家站長寫的一個正則,替換非數字的正則
復制代碼 代碼如下:

function replacestr(str)
dim re
set re=new regexp
re.ignorecase=true
re.global=true
re.pattern="\D"
str=re.replace(str,"")
replacestr=str
set re=nothing
end function

下面是上面的調用方法
復制代碼 代碼如下:

id=replacestr(id)
if len(id)>5 then id=left(id,5)
if id>"" then id=clng(id)
if err.number>0 Or id="0" then response.redirect "https://www.jb51.net"
dim rs
set rs=conn.execute("select id from news where id="id"")

您可能感興趣的文章:
  • asp中cint與clng的區別分析

標簽:宣城 新余 雅安 江門 錫林郭勒盟 儋州 廣元 七臺河

巨人網絡通訊聲明:本文標題《asp cint clng的范圍與防止cint和clng的溢出解決方法大全》,本文關鍵詞  asp,cint,clng,的,范圍,與,防止,;如發現本文內容存在版權問題,煩請提供相關信息告之我們,我們將及時溝通與處理。本站內容系統采集于網絡,涉及言論、版權與本站無關。
  • 相關文章
  • 下面列出與本文章《asp cint clng的范圍與防止cint和clng的溢出解決方法大全》相關的同類信息!
  • 本頁收集關于asp cint clng的范圍與防止cint和clng的溢出解決方法大全的相關信息資訊供網民參考!
  • 推薦文章
    主站蜘蛛池模板: 武强县| 金昌市| 阿城市| 兴义市| 从化市| 理塘县| 郴州市| 岳池县| 雅安市| 调兵山市| 凭祥市| 普安县| 义马市| 锦州市| 岚皋县| 阿克陶县| 宣汉县| 合江县| 澄迈县| 祁东县| 兴文县| 卫辉市| 于都县| 沅江市| 东乌| 微山县| SHOW| 苍梧县| 文成县| 莒南县| 桃园市| 伊金霍洛旗| 盐山县| 西峡县| 湟中县| 个旧市| 通化县| 县级市| 台中县| 阳东县| 遂宁市|