Solved

Using COLLECTIONS save memory over Arrays?!?

Posted on 1999-01-20
3
135 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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

828 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