Autor Beitrag
Satego
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 48

Vista

BeitragVerfasst: Di 25.03.08 15:09 
Wenn ich ein Array of tedit erstelle muss ich z.b.
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
felder[1]:= edit1;
felder[2]:= edit2;
felder[3]:= edit3;
felder[4]:= edit4;
felder[5]:= edit5;
felder[6]:= edit6;
felder[7]:= edit7;
 ....


eingeben damit die Schleife funktioniert.

Wie kan ich das verkürzen?

Lg

Moderiert von user profile iconChristian S.: Delphi-Tags hinzugefügt

_________________
motivierter Anfänger ;)
Gausi
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 8554
Erhaltene Danke: 481

Windows 7, Windows 10
D7 PE, Delphi XE3 Prof, Delphi 10.3 CE
BeitragVerfasst: Di 25.03.08 15:20 
Stichwort ist FindComponent. In einer for-Schleife kann man das dann so machen:
ausblenden Delphi-Quelltext
1:
felder[i] := TEdit(FindComponent('edit' + IntToStr(i)));					

_________________
We are, we were and will not be.
Satego Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 48

Vista

BeitragVerfasst: Di 25.03.08 16:45 
muss ich das in die Schleife schreiben oder oberhalb? Weil ich bekommen nur eine Fehlermeldung.
lg

_________________
motivierter Anfänger ;)
Christian S.
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 20451
Erhaltene Danke: 2264

Win 10
C# (VS 2019)
BeitragVerfasst: Di 25.03.08 16:48 
user profile iconSatego hat folgendes geschrieben:
muss ich das in die Schleife schreiben oder oberhalb? Weil ich bekommen nur eine Fehlermeldung.
lg
Da i die Schleifenvariable ist, macht nur eine der beiden Varianten Sinn :zwinker:

_________________
Zwei Worte werden Dir im Leben viele Türen öffnen - "ziehen" und "drücken".
Satego Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 48

Vista

BeitragVerfasst: Di 25.03.08 16:55 
Weiß jetzt nicht was du meinst, hier ist mal der Code:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
var i :integer;
begin

box[i]:=TCombobox(FindComponent('combobox' + IntToStr(i)));

for i := 1 to 6 do begin   
  box[i].visible:=false;
end;


Moderiert von user profile iconChristian S.: Delphi-Tags hinzugefügt

_________________
motivierter Anfänger ;)
Christian S.
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 20451
Erhaltene Danke: 2264

Win 10
C# (VS 2019)
BeitragVerfasst: Di 25.03.08 16:57 
Welchen Wert hat i in Zeile 4?

_________________
Zwei Worte werden Dir im Leben viele Türen öffnen - "ziehen" und "drücken".
Kroko
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 1284

W98 W2k WXP
Turbo D
BeitragVerfasst: Di 25.03.08 16:57 
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
var i :integer;
begin

for i := 1 to 6 do 
begin
  box[i]:=TCombobox(FindComponent('combobox' + IntToStr(i)));
  box[i].visible := False;
end;

Du must schon jedesmal die richtige Box suchen lassen!

_________________
Die F1-Taste steht nicht unter Naturschutz und darf somit regelmäßig und oft benutzt werden! oder Wer lesen kann, ist klar im Vorteil!
Satego Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 48

Vista

BeitragVerfasst: Di 25.03.08 17:03 
Dankeschön :zustimm:

_________________
motivierter Anfänger ;)