Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Object-Pascal / Delphi-Language (https://www.delphipraxis.net/32-object-pascal-delphi-language/)
-   -   Delphi List index out of (50) (https://www.delphipraxis.net/114090-list-index-out-50-a.html)

Stelo 19. Mai 2008 16:01


List index out of (50)
 
Hallo,
ich habe da mal ein kleines Problem. Und zwar geht es um folgenden kleinen Code-Ausschnitt:

for i:=50 downto 1 do
begin
zeile := tabelle[i];
end;

Von i:= 1 bis 49 gibt es keine Probleme, aber ab 50 erhalte ich jedes mal die Fehlermeldung:
"List index out of (50)"

Achso, tabelle ist übriges vom Typ TStringList, hängt das irgendwie damit zusammen?

Danke schon mal für die Hilfe! ;)

Die Muhkuh 19. Mai 2008 16:04

Re: List index out of (50)
 
Wie sieht den die Stringliste aus?
Wieviele Einträge hat sie?

Wenn Du 50 Einträge in der Stringlist hast, musst Du von 0 bis 49 bzw. von 49 bis 0 zählen, um alle Einträge zu bekommen.

DeddyH 19. Mai 2008 16:05

Re: List index out of (50)
 
Mach es besser so:
Delphi-Quellcode:
for i:=tabelle.Count - 1 downto 0 do
  begin
    zeile := tabelle[i];
  end;

Die Muhkuh 19. Mai 2008 16:07

Re: List index out of (50)
 
Mach es gleich so:

Delphi-Quellcode:
zeile := tabelle[0];
Kommt in dem Fall aufs gleiche raus. :zwinker:

Stelo 19. Mai 2008 16:10

Re: List index out of (50)
 
Stimmt. Ich habe das Count - 1 vergessen. :wall:

Jetzt scheint es zu funktionieren! :) Vielen Dank! ;)


Alle Zeitangaben in WEZ +1. Es ist jetzt 20:16 Uhr.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz