•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the Pascal and Delphi section within the Software Development category of DaniWeb, a massive community of 455,969 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,760 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our Pascal and Delphi advertiser: Programming Forums
Views: 709 | Replies: 2
![]() |
| |
•
•
Join Date: Nov 2007
Posts: 29
Reputation:
Rep Power: 2
Solved Threads: 0
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[i].Caption:=Anaform.Memo[i].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 .....
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[i].Caption:=Anaform.Memo[i].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 .....
•
•
Join Date: Oct 2007
Location: Cherry Hill, NJ
Posts: 1,878
Reputation:
Rep Power: 13
Solved Threads: 193
Look in your documentation for TComponent.FindComponent.
You can say something like:
Untested!
You can say something like:
Delphi Syntax (Toggle Plain Text)
for i := 1 to 50 do tLabel(DisplayForm.findComponent('Label' +intToStr(i))).caption := tMemo(AnaForm.findComponent('Memo' +intToStr(i))).lines[0];
Last edited by Duoas : Nov 26th, 2007 at 12:22 pm.
![]() |
•
•
•
•
•
•
•
•
DaniWeb Pascal and Delphi Marketplace
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
- a block of python codes in a loop (Python)
- Finished my code, it compiles, but when i use build bersion, there is always an error (C++)
- Tic-Tac-Toe (C++)
- My loop won't work, but I'm positive it should. (Python)
- Help w/ for loop. (C++)
- need help w/for loop (C++)
- merged:nesting loops (C++)
- Help with error checking code (C++)
- File parsing in 'C' (C)
Other Threads in the Pascal and Delphi Forum
- Previous Thread: label
- Next Thread: A few questions to finish up my project



Hybrid Mode