Sub Activity_Create(FirstTime As Boolean)
Log(IsValidIp("192.168.1.83"))
Log(IsValidIp("192.168.2221.83"))
End Sub
Sub IsValidIp(ip As String) As Boolean
Dim m As Matcher
m = Regex.Matcher("^(\d+)\.(\d+)\.(\d+)\.(\d+)$", ip)
If m.Find = False Then Return False
For i = 1 To 4
If m.Group(i) > 255 OR m.Group(i) < 0 Then Return False
Next
Return True
End Sub
As you see I combine RegEx with some code. It is much easier to validate it this way.