How To Allow Only Numbers In TextBox Control?

 Posted by Vishalneeraj-24503 on 4/26/2015 | Category: Visual Studio Interview questions | Views: 1986 | Points: 40

We will use Regex.IsMatch method to alow only numbers.
For working with Regex classes,we have to import
System.RegularExpression Namespace.
Using System.RegularExpression.

if (!Regex.IsMatch(txtNumbersOnly.Text,
MessageBox.Show("Not a Number");

Asked In: Many Interviews | Alert Moderator 

Comments or Responses

Login to post response