No announcement yet.

abusing LISTBOXes (VB6 port)

  • Filter
  • Time
  • Show
Clear All
new posts

  • abusing LISTBOXes (VB6 port) seems to be using a collection object as a variable-length array. We don't have collection objects or C++esque vectors, so it seems a hidden LISTBOX would be an easy way to provide the illusion of a variable-length array. Are there any pitfalls to be aware of, besides the Win9x limit of 32767 elements in a LISTBOX?
    Erich Schulman (KT4VOL/KTN4CA)
    Go Big Orange

  • #2
    Is there any reason you can't use an array of strings to store the names of the subdirectories?


    • #3
      You don't know the actual number in advance. Even if I calculated the absolute maximum number of directories a NTFS partition could hold, there is still the possibility of reading multiple NTFS partitions and/or mounting a ext3 partition or non-partitioned media.

      I could DIM for 0 TO 999999 and assume I will probably never run out, but I tend to have an aversion to 640K ought to be enough for anyone assumptions. But I think I would rather allocate an enormous array than have to deal with periodic REDIM PRESERVE's.
      Erich Schulman (KT4VOL/KTN4CA)
      Go Big Orange


      • #4
        An "array of strings" need not be a PB Array requiring DIM/REDIM.

        It can be a simple delimited string, with each string ending with a known delimiter character such as $NUL or $TAB. Just concatenate as you build. If you want that data in a PB array for manipulation purposes after it's built, just PARSE the string into that array at that time.

        BTW, re REDIM PRESERVE usage.... I would like a nickel for everytime I've written code similar to ..
         WHILE condition 
              INCR  nITem           ' add an item to array 
              IF nItem > UBOUND (target_array) THEN 
                 REDIM PRESERVE target_array (nItem + %ITEM_INCREMENT) 
              END IF 
         REDIM PRESERVE target_array (nITem)   ' size to fit when done
        Without volumes it's hard to tell if either approach makes sense, but if you were thinking about a "hidden listbox" I think it's safe to say your volumes are low enough for either method to work.

        Michael Mattias
        Tal Systems (retired)
        Port Washington WI USA
        [email protected]


        • #5
          ...or use a tree structure which would allow sorting to be done as the tree is built. Or even a tree inside a dynamic string.