在DELPHI中,用什么函数来判断一个变量是否为数字,就象VB中的ISNUMERIC?

解决方案 »

  1.   

    随手写的function IsNumeric(str: string): boolean;
    begin
      result := false;
      if trim(str) = '.' then
        result := false
      else
      begin  
      try
        strtofloat(str);
        result := true;
      except
      
      end;
      end;
    end;
      

  2.   

    function IsNumeric(c: char): Boolean;
      

  3.   

    不知道是DELPHI5还是什么原因,好象没有isnumber这个函数。
    木鱼君的函数是不错。但用错误处理机制得到好象有点不太妥吧。总之谢谢你们
      

  4.   

    不知道是DELPHI5还是什么原因,好象没有isnumber这个函数。
    木鱼君的函数是不错。但用错误处理机制得到好象有点不太妥吧。总之谢谢你们
      

  5.   

    IsNumeric?
    是内置的还是包含在某个单元文件里面?为什么我这里引用不到?
      

  6.   

    delphi中好像没有IsNumeric这个函数,pb和cb中好像有
      

  7.   

    没有?太遗憾了,这么强大的编程工具少了这个shrug
      

  8.   

    function isnumber(s:string):boolean;
    var v:float;code:integer;
    begin
      val(s,v,code);//S为判断源,V为转换后数字,CODE为转换时的错误码(表示转换到第CODE位时出错)
      if v>0 then
         result:=false//不是数字
      else
         result:=true;
    end;
      

  9.   

    不好意思,写错了,应该是
    IF code>0 then