获取输入字的个数
int TitleWordCnt( CString name, int wordcnt )
{
int pTempCnt = 0;
int rtn = 0;
UCHAR chr;
while( pTempCnt < wordcnt )
{
chr = name.GetAt(pTempCnt);
if(chr>=0x81)
{
rtn++;
pTempCnt+=2;
}
else if((name.GetAt(pTempCnt)>='a')&&(name.GetAt(pTempCnt)<='z'))
{
rtn+=1;
pTempCnt++;
while((name.GetAt(pTempCnt)>='a')&&(name.GetAt(pTempCnt)<='z'))
pTempCnt++;
while((name.GetAt(pTempCnt)>='A')&&(name.GetAt(pTempCnt)<='Z'))
pTempCnt++;
while((name.GetAt(pTempCnt)>='0')&&(name.GetAt(pTempCnt)<='9'))
pTempCnt++;
}
else if((name.GetAt(pTempCnt)>='A')&&(name.GetAt(pTempCnt)<='Z'))
{
rtn+=1;
pTempCnt++;
while((name.GetAt(pTempCnt)>='a')&&(name.GetAt(pTempCnt)<='z'))
pTempCnt++;
while((name.GetAt(pTempCnt)>='A')&&(name.GetAt(pTempCnt)<='Z'))
pTempCnt++;
while((name.GetAt(pTempCnt)>='0')&&(name.GetAt(pTempCnt)<='9'))
pTempCnt++;
}
else if((name.GetAt(pTempCnt)>='0')&&(name.GetAt(pTempCnt)<='9'))
{
rtn+=1;
pTempCnt++;
}
else
{
pTempCnt++;
}
}
return rtn;
}
//int i = TitleWordCnt(str, str.GetLength());
//tmp.Format(_T("%d"),i);
//m_Edit4WordCnt.SetWindowText(_T(""));
//m_Edit4WordCnt.SetWindowText(tmp);
posted on 2011-12-09 16:20 langgonger 阅读(668) 评论(0) 收藏 举报
浙公网安备 33010602011771号