首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > .NET >

delphi的字符串操作(一分钟你就搞定),该如何解决

2012-02-14 
delphi的字符串操作(一分钟你就搞定)现在有6个文本框,字符串S123,456,78,a,b,c怎么把文本框1的值为123,

delphi的字符串操作(一分钟你就搞定)
现在有6个文本框,字符串S='123,456,78,a,b,c'
怎么把文本框1的值为123,文本框2的值为456,文本框3的值为78,……


[解决办法]
edit1.Text:=copy(s,0,3);
edit2.Text:=copy(s,5,3);
edit3.Text:=copy(s,9,2);
.....
[解决办法]
var
s:string;
ts:TStringList;
i,j:integer;
begin
s:='123,456,78,a,b,c';
ts:=TStringList.Create;
while Pos(',',s)>0 do
begin
j:=POS(',',s);
ts.Add(Copy(s,1,j-1));
Delete(s,1,j);
end;
ts.Add(s);
for i:=0 to ts.Count-1 do
TEdit(self.FindComponent('Edit'+IntToStr(i+1))).Text:=ts[i];
ts.Free;

热点排行