用什么方法可得到上字符串(前的sdff,请各位指点,有代码最好。

解决方案 »

  1.   

    uses StrUtils;
    Edit2.Text:=LeftStr(Edit1.Text,4);
      

  2.   

    var
      i:integer;
      tempStr,getstr:string;
    begin
      tempStr:='sdff(为你)' ;
      i:= Pos('(', tempStr)  ;
      getstr:=copy(tempStr,1,Length(tempStr)-i-2);
     // Edit1.Text:=getstr;
    end;
      

  3.   

    用Imj2003(西才)的方法好,但要修正一下:
    Function GetSubStr(tempStr:string):string
    var
      i:integer;
    begin
      getstr:='';
      i:= Pos('(', tempStr)  ;
      If (i<=Length(tempStr)) then getstr:=copy(tempStr,1,i-1);
      Result:=getstr;
    end;
      

  4.   

    Function GetSubStr(tempStr:string):string
    var
      i:integer;
    begin
      getstr:='';
      i:= Pos('(', tempStr)  ;
      If (i<=Length(tempStr)) then getstr:=copy(tempStr,1,i-1);
      Result:=getstr;
    end;
    是可以的
      

  5.   

    lmj2003(西才) 的正确!俺就不重复了:)