验证IP

System.Text.RegularExpressions.Regex r = new System.Text.RegularExpressions.Regex(@"^((2[0-4]\d|25[0-5]|[01]?\d\d?)\.){3}(2[0-4]\d|25[0-5]|[01]?\d\d?)$");
            if (!r.IsMatch(tbServer.Text.Trim()))
            {
                MessageBox.Show("IP格式错误,请重新输入!", "系统提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                tbServer.Focus();
                return false;
            }

 

你可能感兴趣的:(IP)