![]() |
Eine Schleife für die Labels mit Variablenzuordnung(Array)?
Ich habe jetzt schon eine versuche hintermir, haber wie schaffe ich es unten den Text zsammenzufassen?
die Lange Form
Delphi-Quellcode:
Mein Fehlgeschlagener versuch, da ändert sich im Label gar nix:
Form1.Label192.Caption:= IntToStr(Counte[0]) ;
Form1.Label193.Caption:= IntToStr(Counte[1]) ; Form1.Label194.Caption:= IntToStr(Counte[2]) ; Form1.Label195.Caption:= IntToStr(Counte[3]) ; Form1.Label196.Caption:= IntToStr(Counte[4]) ; Form1.Label197.Caption:= IntToStr(Counte[5]) ; Form1.Label198.Caption:= IntToStr(Counte[6]) ; Form1.Label199.Caption:= IntToStr(Counte[7]) ; Form1.Label200.Caption:= IntToStr(Counte[8]) ; Form1.Label201.Caption:= IntToStr(Counte[9]) ;
Delphi-Quellcode:
begin
for x:=0 to 9 do for i:=192 to 201 do (FindComponent('form1.Label'+IntToStr(i)) as TLabel).Caption:=IntToStr(Counte[x]); |
Re: Eine Schleife für die Labels mit Variablenzuordnung(Arra
Hi.
Die innere Schleife wird ja 10x durchlaufen... ;-) Besser so:
Delphi-Quellcode:
//edit: So ein blöder Programmierfehler... :wall:
for i:=0 to 9 do
(FindComponent('Label'+IntToStr(i + 192)) as TLabel).Caption:=IntToStr({ edit: NICHT Counte[x], sondern} Counte[i]); |
Re: Eine Schleife für die Labels mit Variablenzuordnung(Arra
Nein, die Labels
funktionieren auch nicht bei
Delphi-Quellcode:
(FindComponent('form1.Label'+IntToStr(i)) as TLabel).Caption:=IntToStr(Counte[x]);
|
Re: Eine Schleife für die Labels mit Variablenzuordnung(Arra
Könnte es vielleicht am Counte[x] liegen? Einfach mal mit i versuchen. Bei mir funktioniert es mit i.
MfG freak |
Re: Eine Schleife für die Labels mit Variablenzuordnung(Arra
Also so sieht der Spass ganz aus, wo ich die Labels einzeln angegangen bin(siehe oben) hats geklappt
Delphi-Quellcode:
begin
for i:=0 to 9 do Counte[i]:=0; for pl0 := Form1.Anzeige.count-1 DownTo 0 do begin if StrToInt(Form1.Anzeige.Items[pl0]) in [0,10,20,30] then Counte[0] := 0 else Inc(Counte[0]); if StrToInt(Form1.Anzeige.Items[pl0]) in [1,11,21,31] then Counte[1] := 0 else Inc(Counte[1]); if StrToInt(Form1.Anzeige.Items[pl0]) in [2,12,22,32] then Counte[2] := 0 else Inc(Counte[2]); if StrToInt(Form1.Anzeige.Items[pl0]) in [3,13,23,33] then Counte[3] := 0 else Inc(Counte[3]); if StrToInt(Form1.Anzeige.Items[pl0]) in [4,14,24,34] then Counte[4] := 0 else Inc(Counte[4]); if StrToInt(Form1.Anzeige.Items[pl0]) in [5,15,25,35] then Counte[5] := 0 else Inc(Counte[5]); if StrToInt(Form1.Anzeige.Items[pl0]) in [6,16,26,36] then Counte[6] := 0 else Inc(Counte[6]); if StrToInt(Form1.Anzeige.Items[pl0]) in [7,17,27] then Counte[7] := 0 else Inc(Counte[7]); if StrToInt(Form1.Anzeige.Items[pl0]) in [8,18,28] then Counte[8] := 0 else Inc(Counte[8]); if StrToInt(Form1.Anzeige.Items[pl0]) in [9,19,29] then Counte[9] := 0 else Inc(Counte[9]); (FindComponent('form1.Label'+IntToStr(i+192)) as TLabel).Caption:=IntToStr(Counte[i]); end; end; @ freak4fun , nee das will auch nicht funken |
Re: Eine Schleife für die Labels mit Variablenzuordnung(Arra
Hier mein Code.
Delphi-Quellcode:
Poste doch mal deinen Versuch, mit zusammenfassung.
procedure TForm1.Button1Click(Sender: TObject);
var i: Integer; begin for i := 1 to 5 do (FindComponent('Label'+IntToStr(i)) as TLabel).Caption := IntToStr(47); end; MfG freak |
Re: Eine Schleife für die Labels mit Variablenzuordnung(Arra
@freak4fun
Du hast rechts einen "stabilen Wert", was bei mir ja nicht der Fall ist, diese Array will nicht harmonieren mit meinem zeugs. |
Re: Eine Schleife für die Labels mit Variablenzuordnung(Arra
Delphi-Quellcode:
else Inc(Counte[9]);
(FindComponent('form1.Label'+IntToStr(i+192)) as TLabel).Caption:=IntToStr(Counte[i]); end; Das i scheint mit undefiniert. Das ist kein Schleifenzähler mehr, einfach ein fester Wert. Was bekommst du denn als ergebnis? MfG freak |
Re: Eine Schleife für die Labels mit Variablenzuordnung(Arra
meinst Du so
Delphi-Quellcode:
begin
i:=0 ; for i:=0 to 9 do Counte[i]:=0; aber wird i nicht durch
Delphi-Quellcode:
definiert?
for i:=0 to 9 do
|
Re: Eine Schleife für die Labels mit Variablenzuordnung(Arra
Zitat:
MfG freak |
Alle Zeitangaben in WEZ +1. Es ist jetzt 19:41 Uhr. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz