Autor Beitrag
qball
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 47



BeitragVerfasst: Do 24.04.03 17:45 
kann mir jemand einen tipp geben wie ich folgenden code abkürzen kann?
ausblenden Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
cb2.Text:='';
        cb3.Text:='';
        cb4.Text:='';
        cb5.Text:='';
        cb6.Text:='';
        cb7.Text:='';
        cb8.Text:='';
        cb9.Text:='';
        cb10.Text:='';


thx
AndyB
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 1173
Erhaltene Danke: 14


RAD Studio XE2
BeitragVerfasst: Do 24.04.03 17:51 
ausblenden Quelltext
1:
2:
for i := 2 to 10 do
  (cb2.Owner.FindComponent('cb' + IntToStr(i)) as TEdit).Text := '';

_________________
Ist Zeit wirklich Geld?
qball Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 47



BeitragVerfasst: Do 24.04.03 17:58 
danke andyb, hat gefunzt!
Terra23
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 872

Win 8
Delphi 7
BeitragVerfasst: Do 24.04.03 18:36 
@AndyB:

Das ist eine sehr nette Funktion bzw. Prozedur, aber ich hab da mal eine Frage:

Warum startest du mit cd2.Owner? Muß die 2 nicht ermittelt werden? Ich kenne mich da nicht so mit aus, ehrlich gesagt. :oops:

Alex..

_________________
Hasta La Victoria Siempre
AndyB
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 1173
Erhaltene Danke: 14


RAD Studio XE2
BeitragVerfasst: Do 24.04.03 19:04 
Ein FindComponent hätte auch gereicht, nur weiß ich weder ob der Aufruf innerhalb einer Prozedur mit globalen Variablen cb2..cb10 stattfindet, noch, ob die Komponenten von Hand erzeugt oder direkt auf das Formular gelegt wurden. Aus diesen Gründen ging ich auf Nummer sicher und nahm die Owner-Komponente von cb2, deren FindComponent man benötigt.

_________________
Ist Zeit wirklich Geld?