copy(str,1,2);
在str中从第1个开始取2个字符

解决方案 »

  1.   

    function Copy(S; Index, Count: Integer): string;
    得到S中自Index起共Count个字符组成的字符串

    s:='abcd';
    ns:=Copy(s,1,2);
    则ns='ab';
      

  2.   

    Copy(SourceString, StartPos, Count);  复制子串
    Pos(SubString, SourceString);         查找定位
      

  3.   

    for example...
    var Str1,Str2,Str3:String;...
    Str3:=Copy(Str2,Pos(Str1,Str2),Length(Str1));//从Str2中截取Str1上面你提到的trim()是去除字串左右的空格,和VFP中的alltrim()功能一样。
      

  4.   

    ...
    var Str1,Str2,Str3:String;...
    Str3:=Copy(Str2,Pos(Str1,Str2),Length(Str1));
    //作用就是,从Str2中截取Str1,赋值给Str3
    ...
    你提到的Trim()是用来去除字串左右空格的,相当于VFP中的AllTrim()
      

  5.   

    function Copy(S; Index, Count: Integer): string;
    function Copy(S; Index, Count: Integer): array;DescriptionS is an expression of a string or dynamic-array type. Index and Count are integer-type expressions. Copy returns a substring or sub array containing Count characters or elements starting at S[Index]. If Index is larger than the length of S, Copy returns an empty string or array.If Count specifies more characters or array elements than are available, only the characters or elements from S[Index] to the end of S are returned.Note: When S is a dynamic array, Copy can only be used as a parameter in a call to a procedure or function that expects an array parameter. That is, it acts like the Slice function when working with dynamic arrays.
      

  6.   

    pos 函数
    copy 函数
    Saien
      

  7.   

    procedure TForm1.Button1Click(Sender: TObject);
    var
     loc,loc1:integer;
      addr:string;begin
     Addr:=Trim(edit1.Text);
     loc:=pos('#',addr);
     loc1:=loc-1; while (ord(addr[loc1])>48) and (ord(addr[loc1])<57)  do
      loc1:=loc1-1; label1.Caption :=copy(addr,1,loc1);
     label2.Caption :=copy(addr,loc1+1,(loc-1-loc1));
    end;
      

  8.   

    str:='asldfasfd'
    那么str[2]就是's'
      

  9.   

    x:=copy('ABCDEFG',2,3)x就是: 'BCD'
      

  10.   

    若str:='adsfasdf'
    那么str[2]就是'd'
      

  11.   

    可以用copy()函数 copy(字符串,截取的长度,开始截取的字符个数)
    trim() 是用来截取 字符串的前后空格的。
    ================================================================CSDN 论坛助手 Ver 1.0 B0402提供下载。 改进了很多,功能完备!★  浏览帖子速度极快![建议系统使用ie5.5以上]。 ★  多种帖子实现界面。 
    ★  保存帖子到本地[html格式]★  监视您关注帖子的回复更新。
    ★  可以直接发贴、回复帖子★  采用XML接口,可以一次性显示4页帖子,同时支持自定义每次显示帖子数量。可以浏览历史记录! 
    ★  支持在线检测程序升级情况,可及时获得程序更新的信息。★★ 签名  ●  
         可以在您的每个帖子的后面自动加上一个自己设计的签名哟。Http://www.ChinaOK.net/csdn/csdn.zip
    Http://www.ChinaOK.net/csdn/csdn.rar
    Http://www.ChinaOK.net/csdn/csdn.exe    [自解压]