357mag 2 Posted Monday at 08:53 PM I have a program and there is a Edit box and a few buttons. When the program is run, I want to be able to press a button called Show Values and then you will see two lines of code: The value of x is: 6, and The value of y is 7. But I want each line to print on a new line. So I put an sLineBreak in there but it's not working. The second line is just printing after the first line. It should look like this: The value of x is 6 The value of y is 7 Here is my code so far: procedure TFormIncrementAndDecrement.ButtonShowValuesClick(Sender: TObject); var x, y: integer; begin x := 6; y := 7; EditResult.Text := 'The value of x is: ' + IntToStr(x) + sLineBreak; EditResult.Text := EditResult.Text + 'The value of y is: ' + IntToStr(y); Share this post Link to post
Uwe Raabe 2063 Posted Monday at 08:55 PM A TEdit can only show one line. For multi-lines use a TMemo instead. 1 Share this post Link to post
357mag 2 Posted Monday at 09:14 PM Thank You, that is working much better. But when I run my program the words MemoResult show in the Memo control. How do I get rid of them? I've looked in the Object Inspector and I don't see a way to remove them from the Memo contol. Share this post Link to post
Lajos Juhász 295 Posted Monday at 09:40 PM 21 minutes ago, 357mag said: Object Inspector and I don't see a way to remove them from the Memo contol. It is in lines property, Share this post Link to post
357mag 2 Posted Monday at 10:57 PM It still is printing on the same line. Share this post Link to post
357mag 2 Posted Monday at 11:04 PM I got it working now. I forgot to include sLineBreak. Share this post Link to post
Remy Lebeau 1421 Posted Monday at 11:54 PM (edited) In your example, it would be better to use the Lines.Add() method rather than the Text property, then you don't have to worry about using sLineBreak at all, or wasting time and resources to read the Text, append to it, and assign it back. procedure TFormIncrementAndDecrement.ButtonShowValuesClick(Sender: TObject); var x, y: integer; begin x := 6; y := 7; MemoResult.Clear; MemoResult.Lines.Add('The value of x is: ' + IntToStr(x)); MemoResult.Lines.Add('The value of y is: ' + IntToStr(y)); end; Edited Monday at 11:56 PM by Remy Lebeau 1 Share this post Link to post