求使输入的字符串只能由数字组成! 如题,谢谢 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 用isdigit( char c );加以判断int isdigit( int c );Each of these routines returns true if c is a particular representation of a decimal-digit character. 在EDIT中么!?选中number就好了如果不是的话,就做个判断了,查找字符串里面是否全是数字 如果是Edit框 可以选中它的mumber属性 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( "请输入数字 !" ); }} 在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);}可能我有语法错误。 VC绘图的简单问题,在彩色背景色上绘黑线,之后如何擦除黑线,注意是彩色背景 告诉我下怎么把焦点去掉或给别的控件 如何做到窗体透明而组件不透明 用VC画SIN正弦曲线图 怎样在MDI程序里面让 MainFrame获得右键鼠标? 在DLL中弹出对话框程序,弹出的不是MessageBox,而是CDialog. 给大家推荐一个下电子书的地方 有苏州或上海软件公司愿意带我毕业设计吗 智能识别输入字体,定位下拉列表问题,求助 如何制作Web安装程序 请问,如何得到进程的用户名,谢谢,在线等待 哪位牛哥做过在程序代码中实现目录文件压缩、释放操作?
int isdigit( int c );
Each of these routines returns true if c is a particular representation of a decimal-digit character.
{
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( "请输入数字 !" );
}}
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);
}
可能我有语法错误。