[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

TLabel.caption set to ''

Posted on 2000-03-23
5
Medium Priority
?
199 Views
Last Modified: 2010-04-04
If I have a form with 10 labels, and I need to set each caption to '' (nothing), how can I do this without writing each one with this Labelx.Caption := ''; Labely.Caption := '';
etc....

I think an Array of some sort, but I'm not sure...

I have this so far:

procedure TForm1.Button2Click(Sender: TObject);
var
i : Integer;
L: String;
begin
i := 1;
 while i < 10 do begin
  inc(i);
  L := 'Label' + IntToStr(i);
  label1.Caption := L;
  end;
end;

Thanks
0
Comment
Question by:routerboy309
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
5 Comments
 
LVL 3

Accepted Solution

by:
ckaneta earned 200 total points
ID: 2650876
for cnt:= 0 to Form.Componentcount do
 begin
  if (components[cnt] is TLabel) then
   begin
    components[cnt].caption:='';
   end
 end;
0
 
LVL 13

Expert Comment

by:Epsylon
ID: 2650880
var
i : Integer;
L: String;
begin
i := 1;
 while i <= 10 do begin
  L := 'Label' + IntToStr(i);
  TLabel(FindComponent(L)).Caption := L;
  inc(i);
  end;
end;
0
 
LVL 13

Expert Comment

by:Epsylon
ID: 2650887
To clear the Captions you have to use this of course:

TLabel(FindComponent(L)).Caption := '';
0
 

Expert Comment

by:netbeto
ID: 2650888
Just a correct for the ckaneta's source

var cnt : integer;
begin
for cnt:= 0 to Form1.Componentcount -1 do
 begin
  if (components[cnt] is TLabel) then
   begin
    (components[cnt] as TLabel).caption:='';
   end
 end;

this works fine!!

NetBeto.
0
 

Author Comment

by:routerboy309
ID: 2652917
Thanks - worked (with revision from netbeto) as expected.
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…
Suggested Courses

649 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