Working with Dynamic Arrays

Dynamic arrays are used to store a relatively boundless number of array elements. Using dynamic arrays, you can adjust the total number of elements stored in the array (as opposed to a fixed maximum).

How It Works

Using the Redim statement in conjunction with the Preserve parameter, you can dynamically allocate and resize the storage space needed for an array. The Redim statement is used to redefine the number of elements in the array. The Preserve parameter keeps (or preserves) all existing element values as the array size is increased. The Redim statement is often used with loops or the Ubound function (which determines the upperboundary of the array) to increment or decrement the size of the array.


To implement this solution, a loop is used to create the initial array of elements. On the first pass, the array is established, and the first value is assigned. During the following passes, the Preserve parameter is used to retain previous array element values and append values to the array. Using the Ubound function, the upper boundary of the array is identified and incremented (but could also be decremented) and new elements are appended to the array while the previous values are preserved.

Sub Click(Source As Button)

 Dim w As New NotesUIWorkspace
 Dim s As New NotesSession
 Dim db As NotesDatabase
 Dim uidoc As NotesUIDocument
 Dim doc As NotesDocument
 Dim counter As Integer

 Set w = New NotesUIWorkspace
 Set s = New NotesSession
 Set db = s.CurrentDatabase
 Set uidoc = w.CurrentDocument
 Set doc = uidoc.Document

 ' Add elements to array for illustration purposes
 For counter = 0 To 3
 If counter = 0 Then
 Redim myList(0) As String
 myList (counter) = "Element " & counter
 Redim Preserve myList(counter) As String
 myList(counter) = "Element " & counter
 End If

 ' Display initial array
 Msgbox Implode(myList, ", "), , "Array 1"

 'Dynamically add an element to the array
 counter = Ubound (myList) +1
 Redim Preserve myList(counter) As String
 myList(counter) = "Element " & counter

 ' Display dynamic array
 Msgbox Implode(myList, ", "), , "Array 2"
 ' Assign array to an arbitrary field for illustration
 doc.FIELD = myList

End Sub

Create a Custom Popup Dialog Box

An Introduction to the Lotus Domino Tool Suite

Getting Started with Designer

Navigating the Domino Designer Workspace

Domino Design Elements

An Introduction to Formula Language

An Introduction to LotusScript

Fundamentals of a Notes Application

Calendar Applications

Collaborative Applications

Reference Library Applications

Workflow Applications

Web Applications

Design Enhancements Using LotusScript

Design Enhancements Using Formula Language

View Enhancements

Sample Agents

Miscellaneous Enhancements and Tips for Domino Databases

Data Management


Application Deployment and Maintenance


Appendix A. Online Project Files and Sample Applications

Appendix B. IBM® Lotus® Notes® and Domino®Whats Next?

show all menu

Lotus Notes Developer's Toolbox(c) Tips for Rapid and Successful Deployment
Lotus Notes Developers Toolbox: Tips for Rapid and Successful Deployment
ISBN: 0132214482
EAN: 2147483647
Year: N/A
Pages: 293
Authors: Mark Elliott
Similar book on Amazon © 2008-2017.
If you may any questions please contact us: