Link to home
Start Free TrialLog in
Avatar of mmilan
mmilan

asked on

About Memo component

How can I make program which write 10 or more text lines in Memo component (I want to use command FOR...TO...DO)

Thank you for your time!
Avatar of ZifNab
ZifNab

Hi mmilan,

unit Unit1;

interface

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

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

var
  Form1: TForm1;

implementation

{$R *.DFM}

procedure TForm1.Button1Click(Sender: TObject);
var i :integer;
begin
 for i:= 1 to 10 do begin
  memo1.lines.Add('this is line '+IntToStr(i));
 end;
end;

end.


Regards, Zif.
Avatar of mmilan

ASKER

It do NOT work!
??? It did not work?

Open a new application :

put a button on your form
put a memo on your form

replace the unit code with this code I gave you

assign the clickevent of the button to buttonclick

Regards, Zif

Please, specify the errors you get


here is another example:

just open a new application and replace unit code by this one :

unit Unit1;

interface

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

type
  TForm1 = class(TForm)
    procedure FormCreate(Sender: TObject);
    procedure FormDestroy(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
    memo : TMemo;
  end;

var
  Form1: TForm1;

implementation

{$R *.DFM}

procedure TForm1.FormCreate(Sender: TObject);
var i : integer;
begin
 memo := TMemo.Create(Form1);
 memo.Parent := Form1;
 for i := 1 to 10 do begin
  memo.lines.add('this is line '+IntToStr(i));
 end;
end;

procedure TForm1.FormDestroy(Sender: TObject);
begin
 memo.free;
end;

end.

Zif.
Hehehe, Zif !
Seems to me, you get your grading here: it did NOT work....  :-))
Now how to handle this for.. to..do problem ??
Need Help ? ;-))

Greetings, Oli
? Oli, sarcasm? It should work, because I tried it out.. and it worked...
what is wrong with zifnab's answer? it works...
Avatar of mmilan

ASKER

How to give him points? It's Ok now!
ASKER CERTIFIED SOLUTION
Avatar of ZifNab
ZifNab

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of mmilan

ASKER

It's Ok!