Dim str As String = "192.168.1.108" Dim reg As new System.Text.RegularExpressions.Regex("^((?:(?:25[0-5]|2[0-4]\d|((1\d{2})|([1-9]?\d)))\.){3}(?:25[0-5]|2[0-4]\d|((1\d{2})|([1-9]?\d))))$") If reg.IsMatch(str) Then msgbox("正确ip") Else msgbox("错误ip") End If