A
A
Alexander Nikolaevich2016-10-26 09:58:29
Delphi
Alexander Nikolaevich, 2016-10-26 09:58:29

How to split a TStringlist string without a loop?

Let's say there is a string: "Hello world!" in TStringList , how to assign another TStringlist "Hello" without looping ?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander, 2016-10-26
@xpert13

What is the problem and what is the solution:

procedure someProcedure();
var
  s1, s2 : TStringList;
begin
  s1 := TStringList.Create;
  s2 := TStringList.Create;
  try
    s1.LineBreak := ' ';
    s1.Text := 'Hello world!';
    s2.Text := s1.Strings[0];
    ShowMessage(s2.Text);
  finally
    s1.Free;
    s2.Free;
  end;
end;

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question