Code Samples, Tips, Tricks and |
All Content Copyright © 2000 New Vision Software All rights reserved |
| |
Instance |
The following articles deal with custom collection implementations. The first explains how to create a fully functional replacement for the VB collection object and the second describes how to raise events from each of the objects in a collection just like events are raised in a VB control array. The sample projects for each of the articles may be downloaded from the links on this page or on the pages containing the article texts. Create Your Own "Super Collections" in VB Raise Events From Items In Collections Just Like VB Control Arrays More About CSuperCollection The CSuperCollection implementation addresses just about all of the complaints I have ever heard about the VB collection object while maintaining the same functionality as the existing VB object. It has several methods for managing keys including a keys object that can be enumerated using For Each...Next syntax and a KeyExists method. Also present are a move method for items and the ability to assign directly to an item. Something that may prove to be one of the most useful parts of this project is the ability to raise events from any item in the collection, through the collection, returning the index and the key of the item raising the event. I have successfully replaced the VB collection object with CSuperCollection in several existing projects. The replacement was much easier than I expected with very little code alteration required. I hope you find CSuperCollection as useful as I have. Enumerator Fun! Have you ever wondered what goes on under the hood when you execute a For Each...Next loop in VB? Well, the Enumerator Fun sample project shows you how to do an enumeration loop the hard way. The neat part of enumerating a collection in this manner is that you can access all of the methods of the enumerator object used to walk the collection. This gives you much more flexibility in how you access the items in a collection. Have a look at the Enumerator Fun sample project for more details. Download the CSuperCollection sample project (27KB) Download the Collection WithEvents sample project (8KB)
|