MFC vc++判断文本框输入的值是否为数字-编辑框是否数字
办法1:
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 == '.')
MessageBox("是数字");
else
MessageBox("不是数字");
}
办法2:
if(str.SpanIncluding(_T("0123456789.")) == str)
MessageBox("是数字");
else
MessageBox("不是数字');