Autor Beitrag
Sauger Chris
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 228

Win XP, Linux SuSE 9.2
Delphi 4,Delphi 7 Ent.
BeitragVerfasst: Do 24.09.09 14:19 
moin

und zwar spiel ich hier gerade mit 3 listbox komps rum
hier mal der source zu meinem Algorithmus :P


ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
procedure TForm1.Button1Click(Sender: TObject);
begin
if index1 >= 0 then                         //wenn index1 = 0 ist oder größer dann index3 erhöhen
begin
listbox3.Selected[index3] := true;
inc(index3);                              //listbox3 index um 1 erhöhen
end;
if index1 = listbox1.Count  then           //wenn index1 = listbox1 ist der durlauf fertig
begin
Showmessage('Fertig');
end;
if index2 = listbox2.Count-1 then          //wenn index2 = listbox2 ist dann auf 0 stellen
begin                                    //ready für neuen durchlauf
index2 := 0;
inc(index1);                            //listbox1 index um 1 erhöhen
listbox1.Selected[index1] := true;
end;
if index3 = listbox3.Count then          //wenn index3 = listbox3 ist dann auf 0 stellen
begin                                    //ready für neuen durchlauf
index3 := 0
inc(index2);                            //listbox2 index um 1 erhöhen
listbox2.Selected[index2] := true;     
end;
end;



ich geb zu der code sieht verdammt komisch aus :) aber ka wieso er mir bei der zweiten listbox immer n fehler raus spuckt "Listenindex überschreitet das Maximum (9)" wenn ich aber einfach weiter den butten klick läuft alles wie es soll
hoffe ihr könnt mir weiter helfen


danke
Einloggen, um Attachments anzusehen!


Zuletzt bearbeitet von Sauger Chris am Do 24.09.09 14:48, insgesamt 2-mal bearbeitet
martin300
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 186
Erhaltene Danke: 2



BeitragVerfasst: Do 24.09.09 14:35 
Bei einer Listbox wird bei 0 begonnen und daher befindet sich das letzte Element auf Anzahl -1;
Sauger Chris Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 228

Win XP, Linux SuSE 9.2
Delphi 4,Delphi 7 Ent.
BeitragVerfasst: Do 24.09.09 14:49 
ok danke

problem lösung

ausblenden Delphi-Quelltext
1:
if index2 = listbox2.Count-1 then   // -1					



danke martin300 ;)