http://www.vb-helper.com/howto_list_subdirectories.html 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?
Announcement
Collapse
No announcement yet.
abusing LISTBOXes (VB6 port)
Collapse
X
-
Is there any reason you can't use an array of strings to store the names of the subdirectories?
-
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
Comment
-
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 ..
Code:WHILE condition INCR nITem ' add an item to array IF nItem > UBOUND (target_array) THEN REDIM PRESERVE target_array (nItem + %ITEM_INCREMENT) END IF Wend REDIM PRESERVE target_array (nITem) ' size to fit when done
MCMMichael Mattias
Tal Systems (retired)
Port Washington WI USA
[email protected]
http://www.talsystems.com
Comment
Comment