怎么样判别一个字符串里的东西是否是数字?我只要得出是或者非。
怎么样判别一个字符串里的东西是否是整数?我只要得出是或者非

解决方案 »

  1.   

    var
      S: String;
      I: Integer;
      B: Boolean;
    begin
      for I := 1 to Length(S) do
      begin
        B := S[I] in ['0'..'9'];
        if B then Break;
      end;
    end;—————————————————————————————————
    宠辱不惊,看庭前花开花落,去留无意;毁誉由人,望天上云卷云舒,聚散任风。
    —————————————————————————————————
      

  2.   

    我记不清了,好象有val()什么的,但具体不知道?
      

  3.   

    if trystrtoint(yourstr,i) then showmessage('是整形')
    i是一个整形数据,随便定义一个就行
      

  4.   

    var
      MyData: Real;
    begin
      try
        MyData:= StrToFloat(str);
        ShowMessage('是数字');
      except
        ShowMessage('不是数字');
      end;
    end;
      

  5.   

    function  Isdigital(const s:string):boolean;
    var i:integer;xsd:integer;
    begin
      result:=true;
      xsd:=0;
      for I := 1 to Length(S) do
      begin
        case s[i] of
          ['0'..'9']:;
          ['.']:inc(xsd);
        else
          begin
            result:=false;
            break; 
          end;
      end;
      result:=result and (xsd<=1); 
    end;
    function  IsInt(const s:string):boolean;
    var i:integer;
    begin
      result:=true;
      for I := 1 to Length(S) do
      begin
        case s[i] of
          ['0'..'9']:;
        else
          begin
            result:=false;
            break; 
          end;
      end;
    end;