CString str; GetDlgItem(IDC_EDIT1)->GetWindowText(str); char c; for(int i=0;i<str.GetLength();i++) { c = str.GetAt(i); if(c> = '0 '&&c <= '9 ' || c=='.'){//符合数字的条件} else MessageBox( "发现非数字存在! ", "提示 ",MB_OK); }