The resource has not been reviewed by Editors yet. Readers are adviced to use their best judgement before accessing this resource. This resource will be reviewed shortly. If you think this resource contain inappropriate content, please report to webmaster. |
The IsNumeric Function Checks for numeric value.
private void txtPortNo_KeyPress(object sender,System.Windows.Forms.KeyPressEventArgs e)
{
int KeyCode=(int)e.KeyChar;
//Check whether the value is alphanumeric
if(!IsNumeric(KeyCode))
e.Handled=true;
else
e.Handled=false;
}
private bool IsNumeric(int Val)
{
return ((Val>=48 && Val<=57) || (Val == 8) || (Val ==27));
}
To check for IP number the function is given below
private bool IPDotNumeric(int Val)
{
return ((Val>=48 && Val<=57) || (Val == 8) || (Val== 27)||(Val==46));
}
So with this Idea we can customize the Functions to our need.