用toint()转换成int
textbox.text就是字符穿

解决方案 »

  1.   

    public static bool IsNumber(char c);
      

  2.   

    你在csdn里搜索一下,这样的帖子以前有很多的。
      

  3.   

    如果是.net就可以使用约束规则了
      

  4.   

    bool lb=false;
    for(int i=0;i<textBox1.Text.Length;i++)
    if(Char.IsNumber(textBox1.Text,i))
    {
    lb=true;
    break;
    }
    if(lb) 
    MessageBox.Show("number");
    else
    MessageBox.Show("no number");
      

  5.   

    这样只能判断int;加一个条件,判断"."bool lb=false;
    int dot=0;
    if(textBox1.text[0]==".")
    {
    lb=false;
    ...//out no number 
    return
    }
    for(int i=0;i<textBox1.Text.Length;i++)
    {
    if(textBox1.text[0]==".")
    {
    dot ++;
    }if(Char.IsNumber(textBox1.Text,i))
    {
    lb=true;
    break;
    }
    }
    if(lb&&dot<=1)
    MessageBox.Show("number");
    else
    MessageBox.Show("no number");
      

  6.   

    ft:bool lb=false;
    int dot=0;
    if(textBox1.text[0]==".")
    {
    lb=false;
    ...//out no number
    return
    }
    for(int i=0;i<textBox1.Text.Length;i++)
    {
    if(textBox1.text[i]==".")//刚刚错了 应该是text[i] hehe
    {
    dot ++;
    }if(Char.IsNumber(textBox1.Text,i))
    {
    lb=true;
    break;
    }
    }
    if(lb&&dot<=1)
    MessageBox.Show("number");
    else
    MessageBox.Show("no number");
      

  7.   

    ft我是starcbh不用检查"."也行,你test一下.
      

  8.   

    用ISNUMBER()进行判断即可!
      

  9.   

     转换个想法嘛:  
       try
        {
           int iTtmp=Int16,parse(textbox1.text.tostring());
          }
       catch
        {
        MessageBox.Show("您输入的不是数字");
        textBox1.focus();
       return;
         }
      

  10.   

       其实这中方法在其它语言中也是通用的。
    当然你也可以在textBox的keydown中编程,使它只接受数字输入