佳木斯湛栽影视文化发展公司

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

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

熱門標(biāo)簽:Linux服務(wù)器 團(tuán)購網(wǎng)站 科大訊飛語音識別系統(tǒng) 阿里云 服務(wù)器配置 電子圍欄 Mysql連接數(shù)設(shè)置 銀行業(yè)務(wù)

首先我們需要了解的是

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

cint與clng含義:

都可以強制將一個表達(dá)式轉(zhuǎn)換成數(shù)據(jù)類型

cint與clng處理數(shù)據(jù)的范圍:

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

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

'檢測是否是短整數(shù)

復(fù)制代碼 代碼如下:

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


'檢測是否是長整數(shù)
復(fù)制代碼 代碼如下:

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


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

第一種:
一、檢測它是不是整數(shù) 
復(fù)制代碼 代碼如下:

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  


 

二、檢測它是不是長整數(shù)

復(fù)制代碼 代碼如下:

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  

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

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

下面是上面的調(diào)用方法
復(fù)制代碼 代碼如下:

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的區(qū)別分析

標(biāo)簽:棗莊 蚌埠 廣元 衢州 大理 江蘇 衡水 萍鄉(xiāng)

巨人網(wǎng)絡(luò)通訊聲明:本文標(biāo)題《asp cint clng的范圍與防止cint和clng的溢出解決方法大全》,本文關(guān)鍵詞  ;如發(fā)現(xiàn)本文內(nèi)容存在版權(quán)問題,煩請?zhí)峁┫嚓P(guān)信息告之我們,我們將及時溝通與處理。本站內(nèi)容系統(tǒng)采集于網(wǎng)絡(luò),涉及言論、版權(quán)與本站無關(guān)。
  • 相關(guān)文章
  • 收縮
    • 微信客服
    • 微信二維碼
    • 電話咨詢

    • 400-1100-266
    岫岩| 广水市| 井陉县| 三门峡市| 长寿区| 新化县| 花垣县| 隆安县| 平阳县| 镶黄旗| 错那县| 神农架林区| 莒南县| 乌拉特中旗| 沙坪坝区| 中牟县| 广南县| 昆明市| 行唐县| 梅河口市| 洞口县| 祁连县| 曲阳县| 财经| 安徽省| 朝阳县| 平山县| 韶山市| 满城县| 西充县| 灌阳县| 灵丘县| 永州市| 新泰市| 临夏市| 临汾市| 太康县| 建瓯市| 绥宁县| 孟州市| 兴化市|