How to store Memo contents in string variable in Delphi?

1

I need to store the content of Memo1 in a string variable, but that did not work:

sHTML := Memo1.Lines;
    
asked by anonymous 27.09.2017 / 14:18

3 answers

4
sHTML := Memo1.Text;

This will work, now if you need anything else, please specify in the question.

    
27.09.2017 / 14:19
1

I usually use Memo1.Lines.Text

    
28.09.2017 / 22:51
0

It can be done in the following 3 ways, you can create two memos and one botão in the event onClick of the button pass the following code to it:

procedure TForm1.Button1Click(Sender: TObject);
var i: Integer;
    AText: String;
begin
  Memo2.Lines.Add('Option 1');
  for i := 0 to Memo1.Lines.Count -1 do AText := AText + Memo1.Lines[i];
  Memo2.Text := Memo2.Text + AText;
  Memo2.Lines.Add('--------------------------------------------');

  Memo2.Lines.Add('Option 2');
  AText := Memo1.Lines.Text;
  Memo2.Text := AText;
  Memo2.Lines.Add('--------------------------------------------');

  Memo2.Lines.Add('Option 3');
  AText := Memo1.Text;
  Memo2.Text := Memo2.Text + AText;
  Memo2.Lines.Add('--------------------------------------------');
end;

The second and third option are practically the same, however the first one will only take the text of each line which may be interesting on certain occasions, now everything will depend on your needs.

    
29.09.2017 / 10:34