XArrayDB Reference > XArrayDB Object Methods > DeleteColumns Method (XArrayDB) |
DeleteColumns Method (XArrayDB)
This method deletes count columns from an XArrayDB object starting at column index and returns the number of columns successfully deleted.
XArrayDB.DeleteColumns (index, [count])
Arguments
index is a long integer specifying the index of the first column to be deleted.
count is an optional long integer specifying the number of columns to be deleted. If omitted, this argument defaults to 1.
Return Value
A long integer specifying the number of columns successfully deleted.
Method applies to XArrayDB object.
Example
The following example initializes an XArrayDB object with 10 rows and 6 columns, then removes the fourth and fifth columns:
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
' remove two columns starting at index 4
Dim result As Long
result = MyArray.DeleteColumns(4, 2)
Debug.Print result ' prints 2
Debug.Print MyArray.Count(2) ' prints 4
Debug.Print MyArray(1, 4) ' prints Row 1, Col 6
' the next line now gives a "Subscript out of range" error
Debug.Print MyArray(1, 5)
See Also