Autor Beitrag
G-McKree
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 178



BeitragVerfasst: Fr 04.04.03 22:42 
ich hab folgende Procedure:
ausblenden Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
procedure TForm1.FormCreate(Sender: TObject);
begin
 Data:= TStringList.Create;
 Data[0]:= '1';
 Data[1]:= '1';
 Data[2]:= '1';
 Data[4]:= '';
 Data[5]:= '';
 Data[6]:= '';
 Data[7]:= '';
 Data[8]:= '';
 Data[9]:= '';
 Data.Free;
end;


und Delphi findet da immer na access violation drin, habt ihr ne
Ahnung wo der Fehler is?

Moderiert von user profile iconUGrohne: Quote-Tags durch Code-Tags ersetzt
G-McKree Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 178



BeitragVerfasst: Fr 04.04.03 22:47 
nicht access violation, sondern ''index out of bounds'' Wie bringe ich die TStringList nun dazu, dass sie diese indexe hat?
wulfskin
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 1349
Erhaltene Danke: 1

Win XP
D5 Pers (SSL), D2005 Pro, C, C#
BeitragVerfasst: Fr 04.04.03 23:14 
Hallo McKree!

So geht das nicht, denn es existieren die "Linien" 0-9 noch nicht. Deshalb musst du diese erst erstellen, bevor du ihnen was zuweisen kannst und das geht so:
ausblenden Quelltext
1:
2:
3:
4:
5:
var
  I: Integer;
begin
  for I := 0 to 9 do
    Data.Lines.Add(''); //nix
Wenn du allerdings nur 10 "Linien" brauchst, dann empfielht sich eher ein statischer Array of String!

Gruß wulfskin!

_________________
Manche antworten um ihren Beitragszähler zu erhöhen, andere um zu Helfen.