string regexString="((2[0-4]//d|25[0-5]|[01]?//d//d?)//.){3}(2[0-4]//d|25[0-5]|[01]?//d//d?)";
Regex regex=new Regex(regexString);
//this.txtIP.Text is user input value
if (!regex.Match(this.txtIP.Text).Success)
{
b = false;
MessageBox.Show("IP Address Format is Incorrect");
this.txtIP.EditValue = "";
}