在vb中是有这么一个函数,叫 isnumeric() 什么的。请问在delphi有这样一个可以判断字符串的字符全是数字的函数吗?叫什么?

解决方案 »

  1.   

    function Is_Numeric(SS :string ): Boolean ;
    var i :integer ;
    begin
      for i := 0 to Length(ss)  do
      begin
        if ss[i] not in ['0'...'9' ] then
        begin
          Result  := False ;
          Exit ;
        end ;
        Result := true ;
      end ;
    end ;
      

  2.   

    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;自己写一个吧
      

  3.   

    try
      StrtoInt(Str)
      Result:=True;
    except
      Result:=False;
    end;
    方法多的很关键在与人想
      

  4.   

    同意空间在线 的这些简单的自己写个function就行了
      

  5.   

    这个咯
    const
     def=0;
    ......var
     i:integer;
    .....
    i:=StrToIntDef(YourStr,def);
    if i<>0 then 全是数字
      

  6.   

    SydPink(呜噜~呜噜) 的方法是好方法(不需要自己写try..except..end),不过还是要稍微修正一下:
    当YourStr输入为‘0’时,算法出错