In a TMemo field I have 3 lines:
- line1
- line2
- line3
Is it posible to get all three lines as one string?
Example:
line1,line2,line3
In a TMemo field I have 3 lines:
Is it posible to get all three lines as one string?
Example:
line1,line2,line3
You can use the Lines.CommaText property for this. Do the following:
CommaString := Memo1.Lines.CommaText;
Its also useful to use the DelimitedText property if you want the text to make use of another separator character. You can do that by using something like this:
Memo1.Lines.Delimiter := '-';
Memo1.Lines.StrictDelimiter := True;
DashString := Memo1.Lines.DelimitedText;
This works both ways. You can assign a value to the CommaText or DelimiterText to set the lines. This is actually a of TStringList so it will work with TListBox, TMemo, TComboBox, etc. Basically anything that uses a string list internally.
maybe something like this suits your needs
d:=memo1.lines.count;
for i:=1 to d do
memo1.lines[0]:=memo1.lines[0]+' '+memo1.lines[i];
for i:=1 to d do
memo1.lines.Delete(1);
here is a 3 line function that do it.
function getOneLineMemo(memo:Tmemo):String;
var
i:integer;
begin
result := '';
for i:=0 to memo1.lines.count do
result := result + memo.lines[0];
end;