Imports System.Text.RegularExpressions
Dim pattern As String = "((25[0-5]|2[0-4]\d|1?\d{1,2})\.){3}(25[0-5]|2[0-4]\d|1?\d{1,2})"
Dim re As New Regex("^" & pattern & "$")
Dim text As String = txtIPAddress.Text
If Not re.IsMatch(text) Then
' textbox contents isn't correct
End If