Solved

About Memo component

Posted on 1999-01-07
10
238 Views
Last Modified: 2012-05-04
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!
0
Comment
Question by:mmilan
10 Comments
 
LVL 8

Expert Comment

by:ZifNab
ID: 1355132
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.
0
 

Author Comment

by:mmilan
ID: 1355133
It do NOT work!
0
 
LVL 8

Expert Comment

by:ZifNab
ID: 1355134
??? 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


0
Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

 
LVL 8

Expert Comment

by:ZifNab
ID: 1355135
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.
0
 
LVL 1

Expert Comment

by:Oli2
ID: 1355136
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
0
 
LVL 8

Expert Comment

by:ZifNab
ID: 1355137
? Oli, sarcasm? It should work, because I tried it out.. and it worked...
0
 

Expert Comment

by:theraphy
ID: 1355138
what is wrong with zifnab's answer? it works...
0
 

Author Comment

by:mmilan
ID: 1355139
How to give him points? It's Ok now!
0
 
LVL 8

Accepted Solution

by:
ZifNab earned 20 total points
ID: 1355140
Hi mmilan,

I just answer it again.

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.
0
 

Author Comment

by:mmilan
ID: 1355141
It's Ok!
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

813 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now