Results 1 to 7 of 7

Thread: ListBox Size Limit - Any Way To Increase It?

  1. #1

    Thread Starter
    Member friendsofwatto's Avatar
    Join Date
    Jan 2003
    Location
    Aussie-land
    Posts
    52

    ListBox Size Limit - Any Way To Increase It?

    Hi,

    I have about 43000 items I need to display in a listbox. I add all the items to the listbox by using a loop like so...

    VB Code:
    1. arraypos = 0
    2. Do While (arraypos < 43000)
    3. List1.AddItem("File " & arraypos)
    4. arraypos = arraypos + 1
    5. Loop

    When the arraypos number reaches 32736, VB returns the following error message "Invalid procedure call or argument" - which is runtime error 5

    The error highlights the line which adds the text to the list

    The program works perfectly fine when I limit the number of times it does the loop to a number less than 32736
    ie. Do While (arraypos < 32736)

    I presume that there is a limit on the number of items allowed in a listbox. Is there any way I can increase the limit on the listbox to a higher number?


    Thanks guys.

    WATTO
    [email protected]
    http://www.watto.org
    "There is no such thing as a coincidence" - Tegan Sneddon 2002

  2. #2
    The Devil crptcblade's Avatar
    Join Date
    Aug 2000
    Location
    Quetzalshacatenango
    Posts
    9,091
    Sorry, the listbox control is limited in the amount of items it can hold. Try a Listview instead. Its limited only by available memory.
    Laugh, and the world laughs with you. Cry, and you just water down your vodka.


    Take credit, not responsibility

  3. #3
    Frenzied Member McGenius's Avatar
    Join Date
    Jan 2003
    Posts
    1,199
    Listbox.Listindex is an Integer and therefore cannot take more than maximum allowed. Integer can hold upto 32,767 but since ListIndex is ZERO based - the upper bound is 32,766 and there is no way arround.
    What you may do is use an array but display in the Listbox part of it (let's say 100 entries). It's very simple to implement. Also loading more than few hundred recorrds in the list isn't reasonable anyway - no one will be looking through so many of them.
    McGenius

  4. #4
    I'm about to be a PowerPoster! kleinma's Avatar
    Join Date
    Nov 2001
    Location
    NJ - USA (Near NYC)
    Posts
    23,373
    Originally posted by McGenius
    Also loading more than few hundred recorrds in the list isn't reasonable anyway - no one will be looking through so many of them.
    seriously.. if i was using an application.. and a listbox had 40k+ entires for me to choose from... i would want to shoot the programmer there should be some way of limiting it... what does the listbox contain that someone would have to pick from so many?

  5. #5
    Frenzied Member McGenius's Avatar
    Join Date
    Jan 2003
    Posts
    1,199
    Originally posted by kleinma
    seriously.. if i was using an application.. and a listbox had 40k+ entires for me to choose from... i would want to shoot the programmer there should be some way of limiting it... what does the listbox contain that someone would have to pick from so many?
    LOL, indeed ...
    McGenius

  6. #6

    Thread Starter
    Member friendsofwatto's Avatar
    Join Date
    Jan 2003
    Location
    Aussie-land
    Posts
    52
    Yeah, I know, 40000 files is a lot to sort through

    The program I am making is an archive reader - kinda like winzip. My program opens *.dat archives (used by Maxis) and writes the file names of each entry in the archive into the listbox. It just happens that 1 archive I an trying to display has 40000+ files in it.

    I was thinking of splitting the array in half, but only if there wasn't any other way to display them all at once.

    Oh, and what is that ListView thing, and how is it used?


    Thanks guys.

    WATTO
    [email protected]
    http://www.watto.org
    "There is no such thing as a coincidence" - Tegan Sneddon 2002

  7. #7
    Former Admin/Moderator MartinLiss's Avatar
    Join Date
    Sep 1999
    Location
    San Jose, CA
    Posts
    33,431
    You could also consider having an A-B-C-D set of selection buttons (as a control array) and split your listbox into a control array of 26 listboxes. They could all be placed on top of each other with all but the "A" listbox set to hidden, and then you could simply make the proper listbox visible depending on which of the A-B-C-D buttons was pressed.

Posting Permissions

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



Click Here to Expand Forum to Full Width