Again hi. I want to learn about how I will write these two components :Label and Memo using one loop such as "for" loop in delphi. For example: I have 50 memo and I m transferring the strings in line 1 to labels. Can you help me about how I will short the these code lines within one loops
As if :

DisplayForm.Label7.Caption:=Anaform.Memo1.Lines[0];
DisplayForm.Label8.Caption:=Anaform.Memo2.Lines[0];
DisplayForm.Label9.Caption:=Anaform.Memo3.Lines[0];
DisplayForm.Label10.Caption:=Anaform.Memo4.Lines[0];
DisplayForm.Label11.Caption:=Anaform.Memo5.Lines[0];
-------------------------------------------------------------------
-------------------------------------------------------------------
--------------------------------------------------------------------
DisplayForm.Label70.Caption:=Anaform.Memo50.Lines[0];
I want to short in the for loop like that:
for i:=1 to 70 do
begin
displayForm.label.Caption:=Anaform.Memo.Lines[0]
end; thus I will be able to pass values to labels within only one code line instead 50 or 100 code lines.
Regards Ferhat .....

Look in your documentation for TComponent.FindComponent.

You can say something like:

for i := 1 to 50 do
  tLabel(DisplayForm.findComponent('Label' +intToStr(i))).caption :=
  tMemo(AnaForm.findComponent('Memo' +intToStr(i))).lines[0];

Untested!

THANK YOU FOR YOUR HELP. I m very lucky to find a nice professional friends helping and interesting with my problems like you....

This article has been dead for over six months. Start a new discussion instead.