Solved

Using COLLECTIONS save memory over Arrays?!?

Posted on 1999-01-20
3
132 Views
Last Modified: 2010-05-03
I am interested in making several (ie 50) instances of my form which has several controls on it. Is it best to use a Collection or to use an Array instance. I know many of you will say use a Collection instead BUT does it save any more memory than Arrays?  I was playing around and i notice 0 difference in memory savings...so what is the benefit of using Collections over arrays when it comes to having instances of Forms?

Thanks
0
Comment
Question by:ljaques
3 Comments
 
LVL 2

Accepted Solution

by:
VBDesigns earned 0 total points
ID: 1469750
Collections are slower and (I believe) use more memory than arrays.  However, collections allow easy management of data.  Computers are fast enough now a days that collections will do just fine for most data management -- you'll only want to use arrays with speed-specific code that requires instant access to array data.

The advantage to collections is that you can regulate multiple types of objects and variables with them -- Arrays only allow one data type.

Collections also support indexing, and instant 'cleanup' when you remove items from them -- with an array, you need to move the data yourself.

Good luck!
0
 

Author Comment

by:ljaques
ID: 1469751
Thanks very much for that CLEAR answer!
0
 
LVL 1

Expert Comment

by:mogray
ID: 1469752
There is also a nice article on this in last month's VBPJ (visual basic programmer's journal).  The article includes some performance tests and arrays are indeed faster, but as VBDesigns has said, arrays require more bookkeeping on your part.

Regards,
Wayne
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

864 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now