My Blog is my notepad, I want to mark my work anytime, also i can share my harvest with everyone....

Teracy 's space--->

I love BS Develop ,So i am busying as a bee.Do more,Know more,you will get more.....

博客园 首页 新随笔 联系 订阅 管理
一种情况,如果不想让用户在文本框内输入数字类型的字符 在web上可能有很多的判断方法,在cs上我暂时能想到的是try,catch   可是这个效率很低 不想用  在网上找找~~~~~~~~~
 1using System.Text.RegularExpressions
 2//引用命名空间
 3
 4string name=txtname.Text.Trim();
 5string ex=@"^\d*$";
 6Regex reg = new Regex(ex);
 7if(reg.IsMatch(name)==true)
 8{
 9   MessageBox("请填写非数字字符");
10   return;
11}

12else
13   MessageBox("合法字符");

我想这样比起我用try catch 效率要高点吧  ^_^
posted on 2007-09-20 10:09  Teracy  阅读(665)  评论(3编辑  收藏  举报
One Two Three 向“前”走............
frontpage tracking
Sony Style Coupons