View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
GS[_2_] GS[_2_] is offline
external usenet poster
 
Posts: 3,514
Default Use a listbox as a dynamic array?

Robert Crandal expressed precisely :
My VBA program will require multiple dynamic arrays of
strings. These will be "parallel arrays", meaning the arrays
will be the same size, and the indexes of each array will
be related to the corresponding indexes of the other arrays.

So....I decided that I do NOT want to bother using dynamic
arrays for my program, simply because dynamic arrays are
a pain to manage, and other reasons related to the design of
my program.

Instead, I was thinking about creating a few hidden Listbox
controls on a Userform (i.e Visible = False). Then, I could
simply use Listbox.AddItem() to continually add new strings
to the various hidden Listbox's, and possibly remove or
search for strings if necessary.

I'm just curious, but has anybody ever implemented something
like this in their VBA program? How did it work for you?
Were there any problems that I should know about?

What does everybody else think about this idea?

I'd appreciate any comments. Thank you.

Robert


I've ALWAYS found using dynamic arrays much easier to manage, AND get
way better performance than read/write to a control or worksheet. IOW,
your logic (IMO) for using hidden listboxes is flawed because that's
way more complex than just managing the arrays you populate them with.
You need to keep track of which listbox contains what data same as
you'd have to keep track of which array contains what data. Listbox
indexes start at zero; dynamic 2D arrays of ranges start at 1. This
adds to management complexity.

If you have a good naming convention in place then working with arrays
is trivial (so long as you understand array structures)!

--
Garry

Free usenet access at http://www.eternal-september.org
Classic VB Users Regroup!
comp.lang.basic.visual.misc
microsoft.public.vb.general.discussion