Results 1 to 5 of 5

Thread: Listindex(0) out of bounds

  1. #1
    Member
    Join Date
    Mar 2008
    Location
    Etten-Leur
    Posts
    92

    Listindex(0) out of bounds

    Ik heb een programma van Turbo Delphi naar Lazarus omgezet.
    nu krijg ik bij de volgende code bovenstaande foutmelding (EstringListError).

    Code:
    Assignfile(Infile,'Soorten.TXT');
    Reset(Infile);
    I:=0;
    While not EOF(Infile) do
       begin
         readln(Infile,Instring);
         Listbox1.Items[I]:=Instring;
         I:=I+1;
       end;
    closefile(Infile);
    De variabele Instring is als string gedeclareerd.

    Wat is hier fout ?

  2. #2
    Quote Originally Posted by Kees55 View Post
    Code:
    Assignfile(Infile,'Soorten.TXT');
    Reset(Infile);
    I:=0;
    While not EOF(Infile) do
       begin
         readln(Infile,Instring);
         Listbox1.Items[I]:=Instring;
         I:=I+1;
       end;
    closefile(Infile);
    Wellicht dit?

    delphi Code:
    1. Assignfile(Infile,'Soorten.TXT');
    2. Reset(Infile);
    3. While not EOF(Infile) do
    4.    begin
    5.      readln(Infile,Instring);
    6.      Listbox1.Items.Add(Instring);
    7.    end;
    8. closefile(Infile);

    of in 1 regel

    delphi Code:
    1. listbox1.Items.LoadFromFile('Soorten.TXT');

    Bart

  3. #3
    Member
    Join Date
    Mar 2008
    Location
    Etten-Leur
    Posts
    92
    Bedankt, ik heb de laatste optie gekozen en deze werkt goed.

  4. #4
    Senior Member Thaddy's Avatar
    Join Date
    Dec 2004
    Location
    Amsterdam
    Posts
    2,211
    Listbox.Items.Add zou de error ook hebben voorkomen...
    Werken aan Ansi support voor Windows is verspilde tijd, behalve voor historici.

  5. #5
    Fornicatorus Formicidae VideoRipper's Avatar
    Join Date
    Mar 2005
    Location
    Vicus Saltus Orientalem
    Posts
    5,708
    Quote Originally Posted by Thaddy View Post
    Listbox.Items.Add
    Dat gaf Bart ook al als eerste oplossing aan op regel 6
    TMemoryLeak.Create(Nil);

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •