Autor Beitrag
HoddeX
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 23



BeitragVerfasst: Do 04.08.05 14:40 
Ich bekomme die Fehlermeldung, dass der Listenindex das Maximum (1) überschreitet. Wo liegt der Fehler darin? Ich wollte die Stellung der Radiobuttons in einer Stringliste unterbringen.

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:
procedure TF_Haupt.SpeichernClick(Sender: TObject);
var sl: TStringlist;
begin
  ForceCurrentDirectory := TRUE;
  Savedialog1.Filter := 'Zurren-Dateien *.dat|*.dat';
  if not Savedialog1.Execute then Exit;
 sl := TStringlist.Create;
 try
  if RB_Nieder.Checked then sl.Add('1') else sl.Add('0');
   if sl[1] = '1' then RB_Nieder.Checked := TRUE
    else RB_Nieder.Checked := FALSE;

  if RB_Horizontal.Checked then sl.Add('3') else sl.Add('2');
   if sl[2] = '3' then RB_Horizontal.Checked := TRUE
    else RB_Horizontal.Checked := FALSE;

  if RB_Schraeg.Checked then sl.Add('5') else sl.Add('4');
   if sl[4] = '5' then RB_Schraeg.Checked := TRUE
    else RB_Schraeg.Checked := FALSE;

  if RB_Diagonal.Checked then sl.Add('7') else sl.Add('6');
   if sl[6] = '7' then RB_Diagonal.Checked := TRUE
    else RB_Diagonal.Checked := FALSE;
AXMD
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 4006
Erhaltene Danke: 7

Windows 10 64 bit
C# (Visual Studio 2019 Express)
BeitragVerfasst: Do 04.08.05 14:41 
Zeile 10. Der Index beginnt mit [0], nicht mit [1] ;)

AXMD
noidic
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 851

Win 2000 Win XP Vista
D7 Ent, SharpDevelop 2.2
BeitragVerfasst: Do 04.08.05 14:41 
Dein Fehler ist, dass du davon ausgehst, das erste Element der StringList hätte den Index 1. Stimmt aber nicht, hat den Index 0.

_________________
Bravery calls my name in the sound of the wind in the night...
HoddeX Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 23



BeitragVerfasst: Do 04.08.05 16:32 
Vielen Dank für die Hilfe, ihr hattet recht, jetzt funktioniert alles so wie es sein soll! :wink: