这个方法十分简单,只要发现输入的字符串中存在不允许的字符就直接使用 return; 停止后面的程序功能
用于注册时候使用进行非法字符串判断最方便
方法笨了点,不过还比较实用,大家不妨试试^_&
CString str = _T("1234567890dsfdsfdsfsdfsd");
CString strP;
for(int i = 0 ; i <str.GetLength();i++)
{
strP=str.GetAt(i);
//AfxMessageBox(strP);
if(strP=="0" || strP=="1" || strP=="2" || strP=="3" || strP=="4" || strP=="5" || strP=="6" || strP=="7" || strP=="8" || strP=="9" || strP=="A" || strP=="B" || strP=="C" || strP=="D" || strP=="E" || strP=="F" || strP=="G" || strP=="H" || strP=="I" || strP=="J" || strP=="K" || strP=="L" || strP=="M" || strP=="N" || strP=="O" || strP=="P" || strP=="Q" || strP=="R" || strP=="S" || strP=="T" || strP=="U" || strP=="V" || strP=="W" || strP=="X" || strP=="Y" || strP=="Z" || strP=="a" || strP=="b" || strP=="c" || strP=="d" || strP=="e" || strP=="f" || strP=="g" || strP=="h" || strP=="i" || strP=="j" || strP=="k" || strP=="l" || strP=="m" || strP=="n" || strP=="o" || strP=="p" || strP=="q" || strP=="r" || strP=="s" || strP=="t" || strP=="u" || strP=="v" || strP=="w" || strP=="x" || strP=="y" || strP=="z")
{
}
else
{
AfxMessageBox("存在非法字符不允许注册");
return;
}
}