var strs:array of string; cnt:integer; str:string; iPos:integer; begin str:='12345678'; cnt:=Round(Length(str)/2); SetLength(strs,cnt); iPos:=0; while Length(str)>0 do begin strs[iPos]:=LeftStr(str,2); str:=RightStr(str,Length(str)-2); inc(iPos); end;
procedure TForm1.Button1Click(Sender: TObject); var sl1,sl2:string; begin sl1:='12345678'; while Length(sl1)>0 do begin sl2:=sl2+copy(sl1,1,2)+','; Delete(sl1,1,2); end; sl2:=copy(sl2,1,length(sl2)-1); edit1.Text:=sl2;{-----------------EDIT1显示最后的结果} end;
var
strs:array of string;
cnt:integer;
str:string;
iPos:integer;
begin
str:='12345678';
cnt:=Round(Length(str)/2);
SetLength(strs,cnt); iPos:=0;
while Length(str)>0 do
begin
strs[iPos]:=LeftStr(str,2);
str:=RightStr(str,Length(str)-2);
inc(iPos);
end;
procedure TForm1.Button1Click(Sender: TObject);
var
sl1,sl2:string;
begin
sl1:='12345678';
while Length(sl1)>0 do begin
sl2:=sl2+copy(sl1,1,2)+',';
Delete(sl1,1,2);
end;
sl2:=copy(sl2,1,length(sl2)-1);
edit1.Text:=sl2;{-----------------EDIT1显示最后的结果}
end;