2010年04月06日 21:29
Function ArrayIP(a,f)
if f=1 then
if Mid(a,2,1)="." then
ArrayIP=Mid(a,1,1)&".*.*.*"
Exit Function
elseif Mid(a,3,1)="." then
ArrayIP=Mid(a,1,2)&".*.*.*"
Exit Function
elseif Mid(a,4,1)="." then
ArrayIP=Mid(a,1,3)&".*.*.*"
Exit Function
end if
elseif f=2 then
if Mid(a,2,1)="." then
ArrayIP=Left(a,InStr(3,a,"."))&"*.*"
Exit Function
elseif Mid(a,3,1)="." then
ArrayIP=Left(a,InStr(4,a,"."))&"*.*"
Exit Function
elseif Mid(a,4,1)="." then
ArrayIP=Left(a,InStr(5,a,"."))&"*.*"
Exit Function
end if
elseif f=3 then
ArrayIP=Left(a,InstrRev(a,"."))&"*"
Exit Function
end if
ArrayIP="----"
End Function
調用:ArrayIP(IP位址,保留段數)
如ArrayIP(「25.142.52.4」,3),結果就是25.142.52.*
截取失敗則返回「----」