Inheritance is a concept that permits the transfer of data from one class to another class. While common in many programming languages, it is not native to VBA. In the absence of true inheritance, effective coding can help mimic its behavior.
In most situations, Excel objects, such as shapes and buttons, perform simple functions and stand on their own. However, when stored within a class, the opportunity exists to supplement the functionality of custom objects.
There may be situations where a single class property is needed to store multiple values. This can support a list of data or provide the foundation for a loop. VBA classes provide the framework to store arrays as class properties. Overview This is the ninth post in the Tips and …
While VBA collection classes are best known for storing collections of single custom object types, they can also be built into much more complex data structures. This includes storing multiple object collections within a single collection class, permitting a node-like structure to store any number of related items.
A common object structure in VBA is the collection class, where many custom objects are grouped together. VBA also permits additional layers above the collection class, resulting in a collection within a collection. This is a useful technique for organizing hierarchical data or grouping certain objects.
The bubble sort is a commonly used technique for sorting simple arrays and collections. It can also be used to sort through other common VBA data structures, such as two-dimensional arrays, collections of custom objects, and dictionaries.
One feature noticeably absent from VBA is a built-in function to sort arrays and collections. The bubble sort is a well known technique for sorting groups of elements when no native function exists. With a few minor adjustments, a bubble sort can also be used to sort collections of custom …
Class Initialize is known as an intrinsic (native) procedure that triggers when a custom object is initialized. Did you know that this procedure will also work within collection classes? When used properly, class initialize can help set up collections by using default data or loading from saved data.
Previous posts have discussed advantages to using custom objects and custom collections. When used as globals within a VBA, custom objects provide a means of storing complex data structures outside of a standard worksheet. The efficiency gains and ease of access can help you build robust programs. Unfortunately, these custom …
Accessing a specific object within a collection class can be a challenging endeavor. By assigning a proper custom key to objects in a collection class, you can avoid the often cumbersome error handling and loop searches often used to retrieve objects.