|
|
|
|
|
try,catch不行吗?
|
|
|
怎么写啊
|
|
|
try
{ int i=Int32.Parse(tb.Text); MessageBox.Show("是int型"); } catch { MessageBox.Show("不是int型"); } |
|
|
try
{ int tmp = Convert.Toint32(tb.Text.Trim()); MessageBox.Show("YES"); } catch { MessageBox.Show("NO"); } |
|
|
可是我后面要用到i,所以这样写不可以,请高手再次指点,谢谢
|
|
|
pat=@"^(\d{1,9}$)";
r=new Regex(pat,RegexOptions.Compiled); m=r.Match(textbox1.Text); if(!m.Success) { return "文本框中应为整数,请重新输入!"; } |
|
|
楼主的意思是把不是数字的都屏蔽掉?
|
|
|
try{}catch{}太慢了
用正则表达式比较好,stoway正解 |
|
|
gz
|
|