程序代码
function enaddr(sip)'IP编码
esip=cstr(sip)
str1=Left(sip,CInt(InStr(sip,".")-1))
sip=Mid(sip,cint(instr(sip,"."))+1)
str2=Left(sip,cint(instr(sip,"."))-1)
sip=mid(sip,cint(instr(sip,"."))+1)
str3=left(sip,cint(instr(sip,"."))-1)
str4=mid(sip,cint(instr(sip,"."))+1)
enaddr=cint(str1)*256*256*256+cint(str2)*256*256+cint(str3)*256+cint(str4)-1
end function
程序代码
function deaddr(sip) 'IP解码
sip=sip+1
s1=int(sip/256/256/256)
s21=s1*256*256*256
s2=int((sip-s21)/256/256)
s31=s2*256*256+s21
s3=int((sip-s31)/256)
s4=sip-s3*256-s31
deaddr=cstr(s1)+"."+cstr(s2)+"."+cstr(s3)+"."+cstr(s4)
end function
20090522更新两个函数上来:
作用:把长整型数字转为IP地址
程序代码
<%
Function CStrIP(ByVal anNewIP)
Dim lsResults
Dim lnTemp
Dim lnIndex
For lnIndex = 3 To 0 Step -1
lnTemp = Int(anNewIP / (256 ^ lnIndex))
lsResults = lsResults & lnTemp & "."
anNewIP = anNewIP - (lnTemp * (256 ^ lnIndex))
Next
lsResults = Left(lsResults, Len(lsResults) - 1)
CStrIP = lsResults
End Function
%>
作用:把IP地址转为长整型
程序代码
<%
Function CLngIP(ByVal asNewIP)
Dim lnResults
Dim lnIndex
Dim lnIpAry
lnIpAry = Split(asNewIP, ".", 4)
For lnIndex = 0 To 3
If Not lnIndex = 3 Then
lnIpAry(lnIndex) = lnIpAry(lnIndex) * (256 ^ (3 - lnIndex))
End If
lnResults = lnResults + lnIpAry(lnIndex)
Next
CLngIP = lnResults
End Function
%>
新闻热点
疑难解答