如题,谢谢

解决方案 »

  1.   

    用isdigit( char c );加以判断
    int isdigit( int c );
    Each of these routines returns true if c is a particular representation of a decimal-digit character.
      

  2.   

    在EDIT中么!?选中number就好了如果不是的话,就做个判断了,查找字符串里面是否全是数字
      

  3.   

    如果是Edit框 可以选中它的mumber属性
      

  4.   

    void CNumberEdit::OnChange()
    {
    CString s;
    GetWindowText(s);
    CString s2;
    for( int i=0; i<s.GetLength(); i++ )
    {
    char c = s[i];
    if( c >='0' && c <= '9' )
    s2 += c ;
    }
    if( s2 != s )
    {
    SetWindowText("");
    AfxMessageBox( "请输入数字 !" );
    }}
      

  5.   

    在OnChange()事件中进行判断
    CString str;
    GetWindowText(str);
    CString EndStr;
    EndStr = str.mid(str,str.GetLength()-1,1)//获得输入的最后一位
    int bValid = //判断是不是数字或-符号
    if(!bValid)
    {
       str = str.mid(str,0,str.GetLength()-1);
       SetWindowText(str);
    }
    可能我有语法错误。