Solved

Using COLLECTIONS save memory over Arrays?!?

Posted on 1999-01-20
3
131 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
Comment Utility
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
Comment Utility
Thanks very much for that CLEAR answer!
0
 
LVL 1

Expert Comment

by:mogray
Comment Utility
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

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
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…

744 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

15 Experts available now in Live!

Get 1:1 Help Now