博客转移:http://vivianke.blog.163.com/blog/static/29715271200781121246329/
说明:
判断CString对象,即字符串中是否都是数字(包括小数点).
BOOL MyIsNumber(CString str)
{
for(int i = 0; i < str.GetLength(); i++)
{
CString ch = str.GetAt(i);
if((ch!= ".") && (ch != "0") && (ch != "1") && (ch != "2") && (ch != "3") && (ch != "4") && (ch != "5") && (ch != "6") && (ch != "7") && (ch != "8") && (ch != "9"))
return false;
}
return true;
}
作为参考:
IsNumeric()函数
Returns a Boolean value indicating whether an expression can be evaluated as a number.
Syntax
IsNumeric(expression)
The expression argument can be any expression.
Remarks
IsNumeric returns True if the entire expression is recognized as a number; otherwise, it returns False.
IsNumeric returns False if expression is a date expression.