delphidelphi-7tmemo

How do I find out the number of characters in a tmemo component?


What I am trying to do is make a button that takes the amount of chars in a memo and output it in a label

I apologise if this seems like a silly question but I am still learning about Delphi.


Solution

  • The easiest way is to call the Memo's GetTextLen() method:

    Returns the length of the control's text.

    procedure TForm1.Button1Click(Sender: TObject);
    var
      Len: Integer;
    begin
      Len := Memo1.GetTextLen;
      Label1.Caption := IntToStr(Len);
    end;