Option Explicit
Function isInIPSeg(ByVal IP As String, ByVal StartIP As String, ByVal EndIP As String) As Boolean
isInIPSeg = DelIp(IP) > DelIp(StartIP) And DelIp(IP) < DelIp(EndIP)
End FunctionFunction DelIp(strIp) As String
'处理IP节,把未满三位数的 ip 节转换成 三位
'并且去掉分隔符“.”
Dim a() As String
Dim i As Integer
a = Split(strIp, ".")
For i = 0 To UBound(a)
a(i) = Right("000" & a(i), 3)
DelIp = DelIp & a(i)
Next
End FunctionPrivate Sub Form_Load()
MsgBox isInIPSeg("202.117.119.168", "202.117.119.0", "202.117.119.254")
End Sub
Function isInIPSeg(ByVal IP As String, ByVal StartIP As String, ByVal EndIP As String) As Boolean
isInIPSeg = DelIp(IP) > DelIp(StartIP) And DelIp(IP) < DelIp(EndIP)
End FunctionFunction DelIp(strIp) As String
'处理IP节,把未满三位数的 ip 节转换成 三位
'并且去掉分隔符“.”
Dim a() As String
Dim i As Integer
a = Split(strIp, ".")
For i = 0 To UBound(a)
a(i) = Right("000" & a(i), 3)
DelIp = DelIp & a(i)
Next
End FunctionPrivate Sub Form_Load()
MsgBox isInIPSeg("202.117.119.168", "202.117.119.0", "202.117.119.254")
End Sub
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货