I would not use LIKE. Try this:
VB Code:
Option Explicit Private Sub Form_Load() TestAndPrint "a.a.a.a" TestAndPrint "123.123.123.289" TestAndPrint "1.1.1.1" TestAndPrint "123.234.111.1" End Sub Private Sub TestAndPrint(sIP As String) Debug.Print sIP & ": " & IsIP(sIP) End Sub Private Function IsIP(sIP As String) As Boolean Dim Octet() As String Dim i As Integer Octet = Split(sIP, ".") IsIP = False If UBound(Octet) = 3 Then 'We have 4 parameters IsIP = True For i = 0 To 3 If IsNumeric(Octet(i)) Then If Octet(i) < 0 Or Octet(i) > 255 Then 'Not a valid octet IsIP = False Exit For End If Else 'It's not numeric IsIP = False Exit For End If Next i End If End Function




image).
Reply With Quote