如一个字符串'1,2,3,4,5,6,7,8,9',我要以","为分隔符将这个字符串分隔成一个数组,结果是a[0]=1,a[1]=2.........。
解决方案 »
- 想新建一个Frame到工程中,为何出来一个Form 不解啊 相当郁闷
- 散分12(鄙视wintergoes坐我沙发)
- 在一个treeview的node没有子节点了,该node有超链接功能
- 再请教大家一个菜的问题!!!!!!!!!!!!-----------在线等
- 您好,有两个问题,谢谢
- 12M的数据入库居然要4小时
- 用delphi写了有个Dll组件,在服务器上运行错误Access violation
- 提个硬件问题,急啊!
- 两表之间的查询问题! 请高手进!
- ·#¥%—*现在最热的Websnap的问题,有高手就进来看一下,说不定有回报呢?*—%¥#·
- TList排序问题。
- 怎么样才能让DBNavigator能向后滚?
FUNCTION StringToStrings(S: string):Tstrings;
var
Ss: tstrings;
i:int;
begin
Ss := tstrings.create(nil);
i:= Pos(',', S);
while i> 0 do
begin
Ss.add(copy(s,1,i);
s:=copy(s,i,length(s) - i);
end;
result:=Ss;
end;
var
s:string;
i,j,m,n:integer;
str:TStringList;
l:array[0..12] of string;
begin
str:=TStringList.Create;
str.Clear;
s:='1,2,3,4,5,6,7';
i:=length(s);
for j:=0 to i-1 do
begin
if s[j]=',' then
str.Add(inttostr(j));
end;
m:=str.Count;
l[0]:=copy(s,1,strtoint(str.Strings[0])-1);
showmessage(l[0]);
for n:=1 to m-1 do
begin
l[n]:=copy(s,strtoint(str.Strings[n-1])+1,strtoint(str.Strings[n])-strtoint(str.Strings[n-1])-1);
showmessage(l[n]);
end;
if strtoint(str.Strings[m-1])<i then
begin
l[m]:=copy(s,strtoint(str.Strings[m-1])+1,i-strtoint(str.Strings[m-1]));
showmessage(l[m]);
end;end;
a:array of integer;
s:string;
i:integer;
begin
s:='1,2,3,4,5,6';
setlength(a,0);
while pos(',',s)>0 do
begin
setlength(a,high(a)+2);
a[high(a)]:=strtoint(copy(s,1,pos(',',s)-1));
s:=copy(s,pos(',',s)+1,length(s)-pos(',',s));
end;
setlength(a,high(a)+2);
a[high(a)]:=strtoint(s);
self.Caption:='';
for i:=0 to high(a) do
self.Caption:=self.Caption+inttostr(a[i]);
setlength(a,0);
a:=nil;
end;
可以分字符的
var a:array of string;
s:string;
i,j:integer;
begin
s:=edit1.text;
i:=0;
while pos(',',s)>0 do
begin
i:=i+1;
setlength(a,i+1);
setlength(a,high(a)+2);
a[i-1]:=copy(s,1,pos(',',s)-1);
s:=copy(s,pos(',',s)+1,length(s)-pos(',',s));
end;
a[I]:=s;
for j:=0 to i do
showmessage(a[j]) ;end;
Var a:TStringList;
Begin
a :=TStringList.Create;
Try
a.CommaText :='a,b,c,d,e,f,g';
RadioGroup1.Items :=a;
finally
a.Free;
end;
end;
==========================================
你是要这个吗?