Access/VBA Library

Array_

Class to maintain a dynamic array of elementary types.

A lot of methods are designed to use withing shorthand coding. This means you can invoke multiple methods within one line of code. See the example below.

Module: Array_

Remarks

  • Objects can not be stored in an Array_. The private member CheckValue_ checks if the value can be added or not.
  • When invoking a member which has an Index parameter, the specified index should be between 1 and the value of the Count property. This check is performed by the private member CheckIndex_. If Index is invalid, the error "Index of range" (9) will be raised.
Example
 ' Example of shorthand coding
 Dim x As New Array_
 ' Fill the array
 x.Push 1
 x.Push 2
 x.Push "foo"
 x.Push 3
 x.Push 3
 x.Push "foo"
 x.Push 9
 x.Push 2
 ' Now sort
 x.Sort
 ' In reverse order
 x.Reverse
 ' Remove duplicates
 x.Unique
 ' -------------------------------------------
 ' The above lines of code can be replaced by:
 ' -------------------------------------------
 x.FromArray(Array(1, 2, "foo", 3, 3, "foo", 9, 2)).Sort.Reverse.Unique
 ' Both methods give the same result:
 'Array (
 ' [1] = > foo
 ' [2] = > 9
 ' [3] = > 3
 ' [4] = > 2
 ' [5] = > 1
 ')

Topics