例:
s:='aa,bb,cc,dd'
ts := TStringList.Create
ts.Delimter := ','
ts.DelimtedText := s
//這時 ts裏面就存放了 aa bb cc dd 這四個strings了. 妳只要通過 ts[0]就可以取第壹個數據
function SplitString(Source, Deli: string ): TStringList;stdcall;
var
EndOfCurrentString: byte;
StringList:TStringList;
begin
StringList:=TStringList.Create;
while Pos(Deli, Source)>0 do
begin
EndOfCurrentString := Pos(Deli, Source);
StringList.add(Copy(Source, 1, EndOfCurrentString - 1));
Source := Copy(Source, EndOfCurrentString + length(Deli), length(Source) - EndOfCurrentString);
end;
Result := StringList;
StringList.Add(source);
end;
procedure StrToStrs(str:string;strs:tstrings);
var temp:string;
i:integer;
label B,E;
begin
B:
i:= ansipos('|',str);
if i=0 THEN GOTO E;
strs.Add(ansileftstr(str,i-1));
str:=ansirightstr(str,length(str)-i);
GOTO B;
E:
end;