<pre class="brush:delphi">unit UMemoLine;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  StdCtrls;

type
 
TForm1 = class(TForm)
    Memo1: TMemo;
    Button1: TButton;
    Button2: TButton;
    procedure Button1Click(Sender: TObject);
    procedure Button2Click(Sender: TObject);
  private
    { Private 宣言 }
   public
    { Public 宣言 }
  end;

var
  Form1: TForm1;

implementation

{&#36;R *.DFM}

procedure TForm1.Button1Click(Sender: TObject);
begin
  ShowMessage('Linesで行数取得' + IntToStr(Memo1.Lines.Count));
end;

procedure TForm1.Button2Click(Sender: TObject);
begin
  ShowMessage('WinAPIで行数取得' + IntToStr(
    SendMessage(Memo1.Handle, EM_GETLINECOUNT, 0, 0)));
end;

end.
</pre>