急!如何判断一字符串是否为数字串?
kwest 2003-04-08 05:44:08 如何判断一字符串是否为数字串?
如: '123.456000' 为数字,但'+123Edfd我12'为非字符串.
而'+123E-7',为数字串.
Delphi7帮助中:
对function StrToFloat(const S: string): Extended; overload;
中S的定义
S must consist of an optional sign (+ or -), a string of digits with an optional decimal point, and an optional mantissa. The mantissa consists of 'E' or 'e' followed by an optional sign (+ or -) and a whole number. Leading and trailing blanks are ignored.
若S为'+123Edfd我12',通过StrToFloat转换不成功,会引发EConvertError
异常.
能否通过这一点来判断S是否为数字串?(最好能简化为用if 判断)
本人一直以来对异常(C++,Delphi)都不明白,Delphi也刚学不久,望哪位大侠赐教!