//判断字符窜是否为数字
BOOL IsStringNum(const CString &strNum )
{
CString strCheck = strNum;
strCheck.TrimLeft();
strCheck.TrimRight();
if(strCheck.IsEmpty()) return FALSE;
/////////////////////////////////////////////
char chCheck;
for(int i = 0; i < strCheck.GetLength(); i++)
{
chCheck = strCheck.GetAt(i);
if(!::IsCharAlphaNumeric(chCheck))
return FALSE;
if(::IsCharAlpha(chCheck))
return FALSE;
}
return TRUE;
}
BOOL IsStringFloat(const CString &strNum)
{
CString strCheck = strNum;
strCheck.TrimLeft();
strCheck.TrimRight();
if(strCheck.GetLength() == 0) return FALSE;
/////////////////////////////////////////////
if(strCheck.GetAt(0) == '.' || strCheck.GetAt(strCheck.GetLength() - 1) == '.')
return FALSE;
/////////////////////////////////////////////
char chCheck;
int iDotCount = 0;
BOOL bCountDot = FALSE;
int iAfterDotNum = 0;
for(int iIndex = 0; iIndex < strCheck.GetLength(); iIndex++)
{
chCheck = strCheck.GetAt(iIndex);
switch(chCheck)
{
case '0':
case '1':
case '2':
case '3':
case '4':
case '5':
case '6':
case '7':
case '8':
case '9':
{
if(bCountDot)
{
iAfterDotNum++;
if(iAfterDotNum > 2)
return FALSE;
}
break;
}
case '.':
{
iDotCount++;
bCountDot = TRUE;
if(iDotCount > 1) return FALSE;
break;
}
case '-':
{
if(iIndex != 0)
return FALSE;
break;
}
default:
{
return FALSE;
}
}
}
return TRUE;
}