First
- add two textbox ( txtType1, txtType2 )
- add three label ( label1, label2, label3 )
Second
- Right click on textType1 and choose properties
- move to Events and double click on KeyPress
Third
- add this code
//Using 2.0 Framework function TryParse
int isNumber = 0;
int.TryParse(e.KeyChar.ToString(), out isNumber);
if (isNumber == 0)
e.Handled = true;
Second
- Right click on textType2 and choose properties
- move to Events and double click on KeyPress
Third
- add this code
//Using Regular Expressions
if (!System.Text.RegularExpressions.Regex.IsMatch(e.KeyChar.ToString(), "\\d+"))
e.Handled = true;
0 comment:
إرسال تعليق