devxlogo

Tip Bank

Set up event handlers through reflection

Reflection makes it easy to invoke a method (or assign a field or aproperty) by its name. For example, suppose you have the following classes: Class Person Event PropertyChanged(ByVal propertyName

ArrayListJoin – Merging two ArrayList objects

‘ A reusable function that merges two ArrayList objects’ Example:’ Dim al As New ArrayList()’ al.Add(“Jack”)’ al.Add(“Mary”)’ val.Add(“Bob”)’ al.Add(“Tom”)’ ‘ Dim al2 As New ArrayList()’ al2.Add(“Frank”)’ al2.Add(“Lee”)’ al2.Add(“Nick”)’ ‘ al

D

You can use the technique for an “undo” menu/toolbar option. Use a collection instead of a listbox to reduce overhead. Support for both LIFO and FIFO is also included: Public