Board index » delphi » Assigning a memo Field to TMemo component

Assigning a memo Field to TMemo component

Hi, I have a memo field in a database, and I need to do a for..next loop
using its lines property:

for i := 1 to MyDataSet.myMemoField.countLines do
...

I declare a var myMemo and then I created a TMemo component:

myMemo:TMemo
...

myMemo := TMemo.Create(Self);

Now, I want to assign to the myMemo var the text in the database field. How
can I do this?
Its the right way? Or I can use the field directly to do this? Please, help
me.

Thank you

Isildo Mendes
isildo.men...@clix.pt

 

Re:Assigning a memo Field to TMemo component


I did not try yet, but maybe  myMemo.Text := aMemoField.AsString works...

Isildo Mendes schreef:

Quote
> Hi, I have a memo field in a database, and I need to do a for..next loop
> using its lines property:

> for i := 1 to MyDataSet.myMemoField.countLines do
> ...

> I declare a var myMemo and then I created a TMemo component:

> myMemo:TMemo
> ...

> myMemo := TMemo.Create(Self);

> Now, I want to assign to the myMemo var the text in the database field. How
> can I do this?
> Its the right way? Or I can use the field directly to do this? Please, help
> me.

> Thank you

> Isildo Mendes
> isildo.men...@clix.pt

Re:Assigning a memo Field to TMemo component


Quote
Isildo Mendes wrote:
> Hi, I have a memo field in a database, and I need to do a for..next loop
> using its lines property:

> for i := 1 to MyDataSet.myMemoField.countLines do
> ...

> I declare a var myMemo and then I created a TMemo component:

> myMemo:TMemo
> ...

> myMemo := TMemo.Create(Self);

> Now, I want to assign to the myMemo var the text in the database field. How
> can I do this?
> Its the right way? Or I can use the field directly to do this? Please, help
> me.

> Thank you

> Isildo Mendes
> isildo.men...@clix.pt

If you don't need to make decisions based on the content of the lines then just
myMemo.Lines.AddStrings(MyDataSet.MyMemoField.Lines)
otherwise try
for i := 0 to MyDataSet.MyMemoField.Lines.Count-1 do
  if LineIsUseful(MyDataSetMyMemoField.Lines[i])
  then myMemo1.Add(MyDataSetMyMemoField.Lines[i]);

Re:Assigning a memo Field to TMemo component


You can assign it using:

    MyMemo.Lines.Assign(TMemofield(MyDataSet.myMemoField);

--

Woody
(Would a fly without wings be called a walk?)

Quote
Isildo Mendes <rop23...@mail.telepac.pt> wrote in message

news:81tn1h$sth12@forums.borland.com...
Quote
> Hi, I have a memo field in a database, and I need to do a for..next loop
> using its lines property:

> for i := 1 to MyDataSet.myMemoField.countLines do
> ...

> I declare a var myMemo and then I created a TMemo component:

> myMemo:TMemo
> ...

> myMemo := TMemo.Create(Self);

> Now, I want to assign to the myMemo var the text in the database field.
How
> can I do this?
> Its the right way? Or I can use the field directly to do this? Please,
help
> me.

> Thank you

> Isildo Mendes
> isildo.men...@clix.pt

Re:Assigning a memo Field to TMemo component


Quote
> Hi, I have a memo field in a database, and I need to do a for..next loop
> using its lines property:

It has none, of course.

Quote

> for i := 1 to MyDataSet.myMemoField.countLines do
> ....

> I declare a var myMemo and then I created a TMemo component:

You don't need a TMemo unless your intent is to *display* the content of the
field. To just get its data and analyze it you can create a TStringlist object
instead.

  var
    sl: TStringlist;
  begin
    sl:= TStringlist.create;
    try
      sl.Assign( theMemoField );
      ...analyze data in sl
    finally
      sl.free
    end;  

Peter Below (TeamB)  100113.1...@compuserve.com)
No e-mail responses, please, unless explicitly requested!

Other Threads