Search code examples
delphitextlinestmemo

How to edit Text in Memo?


I wanted to use procedure Delete(Memo.Text, index, count) (or similar Insert). But I get message 'Constant object can not be passed as var parameter'. I know I can select text and to use this procedures with Seltext. But this way is a bit uncomfortable. Is there anything easier?


Solution

  • Text is a property rather than a variable. And Delete requires a variable. So you need to use a temporary variable. For instance

    var
      str: string;
    .... 
    str := Memo1.Text;
    Delete(str, index, count);
    Memo1.Text := str;