function StringsToStr(const List: TStrings; Sep: AnsiString): AnsiString;
var
I, L: Integer;
begin
Result := '';
for I := 0 to List.Count - 1 do
begin
// don't combine these into one addition, somehow it hurts performance
Result := Result + List[I];
Result := Result + Sep;
end;
// remove last separator, doing this afterwards saves an if in the loop
if List.Count <> 0 then
begin
L := Length(Sep);
Delete(Result, Length(Result) - L + 1, L);
end;
end;function StrLeft(const S: AnsiString; Count: Integer): AnsiString;
begin
Result := Copy(S, 1, Count);
end;
var
I, L: Integer;
begin
Result := '';
for I := 0 to List.Count - 1 do
begin
// don't combine these into one addition, somehow it hurts performance
Result := Result + List[I];
Result := Result + Sep;
end;
// remove last separator, doing this afterwards saves an if in the loop
if List.Count <> 0 then
begin
L := Length(Sep);
Delete(Result, Length(Result) - L + 1, L);
end;
end;function StrLeft(const S: AnsiString; Count: Integer): AnsiString;
begin
Result := Copy(S, 1, Count);
end;
解决方案 »
- qrpreview控件在哪?
- 100分求一具体代码合并文本并累加计算数据
- 学习编程多年但是仍然一事无成!
- 关于自编组件的事件的一个问题, 高手请进。
- [求助]一个用来生成MDI子窗体的dll的入、出口写法。
- 如何发布C/S的程序??该程序用的是远程数据模块+SocketConnection
- 这段能实现MIME解码吗?具体是怎么使用的呢?小弟困惑不已
- delphi ado 可以连接linux db2 ?怎么连接,都需要配置什么东西
- 怎样保存treeview的树结构?
- TAdvStringGrid
- 有相同结构的数据集A和B,B记录中包含一部分A的内容,要得到C=B-A,怎样用查询语句得到C?
- 各位DELPHI前辈,请问如何在DELPHI中实现“PING”命令,谢谢!!!
如果是字符数组的话,则可用chechy(chechy) 的方法.
如果是字符串的话,不知,你的stri是否都不为空?否则很难判断.
procedure StrToStrings(S: AnsiString; Sep: AnsiString; const List: TStrings);
var
I, L: Integer;
Left: AnsiString;
begin
Assert(List <> nil);
List.Clear;
L := Length(Sep);
I := Pos(Sep, S);
while (I > 0) do
begin
Left := StrLeft(S, I - 1);
List.Add(Left);
Delete(S, 1, I + L - 1);
I := Pos(Sep, S);
end;
if S <> '' then
List.Add(S);
end;
快快快
OK,给分了,谢了先,,,,相你学习哟
var
ST : TStringList;
P : Integer;
begin
P := Pos( ' ', S );
ST := TStringList.Create;
while P > 0 do
begin
ST.Add( Copy( S, 1, P-1 ) );
Delete( S, 1, P );
P := Pos( ' ', S );
end;
Result := ST;
end;procedure TForm1.Button1Click(Sender: TObject);
begin
ListBox1.Items := Split('aabb dfe eafdih effd gadg ee ');
end;