XArrayDB Reference > XArrayDB Object Methods > InsertColumns Method (XArrayDB) |
InsertColumns Method (XArrayDB)
This method inserts count columns into an XArrayDB object starting at column index and returns the number of columns successfully inserted.
XArrayDB.InsertColumns (index, [count])
Arguments
index is a long integer specifying the index of the first column to be inserted.
count is an optional long integer specifying the number of columns to be inserted. If omitted, this argument defaults to 1.
Return Value
A long integer specifying the number of columns successfully inserted.
Method applies to XArrayDB object.
Example
The following example initializes an XArrayDB object with 10 rows and 6 columns, then inserts a new column before the fourth column:
MyArray.ReDim 1, 10, 1, 6
Dim i, j As Integer
For i = 1 To 10
For j = 1 To 6
MyArray(i, j) = "Row " & i & ", Col " & j
Next j
Next i
Debug.Print MyArray(1, 4) ' prints Row 1, Col 4
Debug.Print MyArray(1, 5) ' prints Row 1, Col 5
' insert a new column at index 4
Dim result As Long
result = MyArray.InsertColumns(4)
Debug.Print result ' prints 1
Debug.Print MyArray.Count(2) ' prints 7
Debug.Print IsEmpty(MyArray(1, 4)) ' prints True
Debug.Print MyArray(1, 5) ' prints Row 1, Col 4
Debug.Print MyArray(1, 6) ' prints Row 1, Col 5
See Also