濮阳杆衣贸易有限公司

主頁 > 知識庫 > asp下IP地址分段計算函數(shù)

asp下IP地址分段計算函數(shù)

熱門標簽:宿州防封外呼系統(tǒng)平臺 無營業(yè)執(zhí)照地圖標注教學 高質(zhì)量的電銷外呼系統(tǒng) 地圖標注還可以做嗎 硅基電話機器人加盟 外呼系統(tǒng)怎么話費 滴滴地圖標注上車點 友邦互聯(lián)電銷機器人違法嗎 電銷機器人采購
IP地址分段計算
script language="JScript" Runat="Server">
function IPDeCode(EIP){
var Ip1,Ip2,Ip3,Ip4;
Ip1 = moveByteR(EIP  0xff000000,3);
Ip2 = moveByteR(EIP  0x00ff0000,2);
Ip3 = moveByteR(EIP  0x0000ff00,1);
Ip4 = EIP  0x000000ff;
return Ip1 + "." + Ip2 + "." + Ip3 + "." + Ip4;
}


function moveByteL(num,bytenum){
return num = (bytenum*8)
}

function moveByteR(num,bytenum){
return num >>>= (bytenum*8)
}

/script>


在vbs中沒有位操作,這樣在一個頁面中用到了js和vbs,并不好,如果用vbs也可以,不過羅嗦了一些,而且有一點注意,如果在vbs中split("202.102.29.6","."),會得到202,102,29三個數(shù),得不到最后一個6,所以需要將ip換成split("202.102.29.6"  ".",".")
我用vbs做的,由于沒有位操作,所以做得比較麻煩
%
function ip2int(ipstr)
dim iptemp,max
iptemp = split(ipstr".",".")
max = ubound(iptemp)
if max > 4 then
exit function
end if

dim a,b,i
a = "H"
for i = 0 to 3
b = Hex(iptemp(i))
if len(b) = 1 then
b = "0"b
end if
a = ab
next
ip2int = CLng(a)
end function

function int2ip(ip)
dim iptemp,a,ipstr,i,length
iptemp = Hex(ip)
length = 8 - len(iptemp)
for i = 1 to length
iptemp = "0"  iptemp
next
a = left(iptemp,2)
a = "H"  a
i = CInt(a)
a = CStr(i)
ipstr = a  "."
a = mid(iptemp,3,2)
a = "H"  a
i = CInt(a)
a = CStr(i)
ipstr = ipstr  a  "."
a = mid(iptemp,5,2)
a = "H"  a
i = CInt(a)
a = CStr(i)
ipstr = ipstr  a  "."
a = right(iptemp,2)
a = "H"  a
i = CInt(a)
a = CStr(i)
ipstr = ipstr  a
int2ip = ipstr
end function

dim testIP,testInt
testIP="202.102.29.6"
testInt = ip2int(testIP)
response.write testIP  " will be encoded to font color=red>"  testInt  "/font>br>"
response.write testIP  " will be dencoded to font color=red>"  int2ip(testInt)  "/font>br>"
%> 

 

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

巨人網(wǎng)絡通訊聲明:本文標題《asp下IP地址分段計算函數(shù)》,本文關鍵詞  asp,下,地址,分段,計算,函數(shù),;如發(fā)現(xiàn)本文內(nèi)容存在版權(quán)問題,煩請?zhí)峁┫嚓P信息告之我們,我們將及時溝通與處理。本站內(nèi)容系統(tǒng)采集于網(wǎng)絡,涉及言論、版權(quán)與本站無關。
  • 相關文章
  • 下面列出與本文章《asp下IP地址分段計算函數(shù)》相關的同類信息!
  • 本頁收集關于asp下IP地址分段計算函數(shù)的相關信息資訊供網(wǎng)民參考!
  • 推薦文章
    东乌| 林周县| 阳泉市| 巢湖市| 开远市| 甘孜县| 会同县| 台南市| 旺苍县| 唐河县| 旌德县| 深水埗区| 宜丰县| 侯马市| 湖南省| 馆陶县| 麻江县| 柘荣县| 洪江市| 芦山县| 杭锦后旗| 黄梅县| 类乌齐县| 兖州市| 瑞丽市| 尼勒克县| 绍兴县| 同德县| 类乌齐县| 梁河县| 固始县| 桂平市| 茶陵县| 绩溪县| 兴仁县| 磴口县| 石屏县| 扎鲁特旗| 宜昌市| 寻甸| 扬中市|