Dim url As String = "http://192.168.0.1:8080/123"
Dim m As Integer = url.IndexOf("//")
Dim n As Integer = url.IndexOf("/",m+2)
Dim y As String
If n > -1 Then
y = url.SubString(m+2,n - m - 2)
Else
y = url.SubString(m+2)
End If
If y.Contains(":") Then y = y.Split(":")(0)
Dim yr() As String = y.Split(".")
If yr.Length <> 4 Then
msgbox("不是IP")
Return ""
End If
Dim a As Integer
For i As Integer = 0 To yr.Length - 1
If Integer.TryParse(yr(i),a) AndAlso a < 0 OrElse a > 255
msgbox("不是IP")
Return ""
End If
Next
msgbox("是IP")