我从Delphi的帮助中找到一个函数IsNan,以下是帮助的内容:
function IsNan(const AValue: Single): Boolean; overload;
function IsNan(const AValue: Double): Boolean; overload;
function IsNan(const AValue: Extended): Boolean; overload;
DescriptionUse IsNan to test whether the value specified by AValue represents NaN (not a number). Note that NaN is distinct from positive and negative infinity, which can be detected using the IsInfinite function.我按照帮助写程序,但是编译时提示:Undeclared identifier:'IsNan'
难道帮助是错误的吗?
有没有别的函数判断是否为数字啊?

解决方案 »

  1.   

    谢谢啊,
    还有一个就是,我是这么用这个函数的:
    if IsNan(trim(OID.Text)) then
    编译时提示:
    There is no overloaded version of 'IsNan' that can be called with these arguments
    是不是不能这么用这个函数啊?
    那该怎么用呢?
      

  2.   

    trim(OID.Text)) 的返回值是字符型的.
    类型不匹配
      

  3.   

    function IsNan(const AValue: Single): Boolean; overload;
    function IsNan(const AValue: Double): Boolean; overload;
    function IsNan(const AValue: Extended): Boolean; overload;..................
    说明参数只能是:Single,Double,Extended
      

  4.   

    procedure TForm1.Edit1press(Sender: TObject);if not (key in ['0'..'9','a'..'z','A'..'Z',#8,#13]) thenkey := #0;
      

  5.   

    function StrIsNumber( str : String) : Boolean;
    var
      p   : pchar;
      i   : integer;
      c   : char;
      strVal,strTemp : string;
    begin
      strVal := Trim(str);  if Length(strVal)<=0 then
      begin
        Result := False;
        exit;
      end;  for i := 0 to length(strVal) - 1 do
      begin
        p := Pchar(strVal);
        c := p[i];
        if not IsNumeric(c) then
        begin
            SetLength(strTemp,1);
            strTemp :='.';
            if strTemp <> c then
            begin
              Result := False;
              exit;
            end;
        end;
      end;  Result := True;
    end;
      

  6.   

    function StrIsNumber( str : String) : Boolean;
    var
      p   : pchar;
      i   : integer;
      c   : char;
      strVal,strTemp : string;
    begin
      strVal := Trim(str);  if Length(strVal)<=0 then
      begin
        Result := False;
        exit;
      end;  for i := 0 to length(strVal) - 1 do
      begin
        p := Pchar(strVal);
        c := p[i];
        if not IsNumeric(c) then
        begin
            SetLength(strTemp,1);
            strTemp :='.';
            if strTemp <> c then
            begin
              Result := False;
              exit;
            end;
        end;
      end;  Result := True;
    end;
      

  7.   

    {$HINTS OFF}
    function IsNumeric(AStr: string): Boolean;
    var
      Value: Double;
      Code: Integer;
    begin
      Val(AStr, Value, Code);
      result := Code = 0;
    end;
    {$HINTS ON}
      

  8.   

    在输入框的ONCLICKPRESS事件中:
    if not(key in['0'..'9',#8] then
    begin
    key:=#0;
    messagebeep(1);
    end;
    //#8是删除键,#0是屏蔽输入,messagebeep是警告的声音