如果你想做一个IP查询那么你就要先判断这个IP地址是否合法,下法写一个这样的函数来判断是否合法.
<%
function chk_ip(strIP)
dim boolIsIP
dim arrIP
boolIsIP=true '函数初始值为true
arrIP=split(strIP,".") '将输入的IP用"."分割为数组,数组下标从0开始,所以有效IP分割后的数组上界必须为3
if ubound(arrIP)<>3 then
boolIsIP=false
else
for intLoop=0 to Ubound(arrIP)
if not isnumeric(arrIP(intLoop)) then '检查数组元素中各项是否为数字,如果不是则不是有效IP
boolIsIP=false
else
if arrIP(intLoop)>255 or arrIP(intLoop)<0 then '检查IP数字是否满足IP的取值范围
boolIsIP=false
end if
end if
next
end if
chk_ip=boolIsIp
end function
%>