Difference between revisions of "Insert"

From Xojo Documentation

m (Text replacement - "{{Deprecated|" to "{{DeprecatedItem|")
Line 1: Line 1:
| name=Insert
| name=Insert

Latest revision as of 13:32, 4 January 2021


Inserts a new element into an array. Arrays are zero-based.


array.Insert index, value

Part Type Description
array array of any valid data type The array in which to insert the new element.
index Integer The position in array to insert the new element, i.e., the index of the new element.
value Datatype of array The value to be assigned to the new array element.


The Insert method works with one-dimensional arrays only.

All arrays are indexed starting at position 0. Arrays can have a maximum index value of 2,147,483,646.

Sample Code

Suppose array "a" is defined as:

a = Array("Leonard", "Adolph", "Herbert")

The statement:

a.Insert(2, "Bill")

results in the following array:

Array Element

See Also

Append, Array, IndexOf, Pop, Redim, Remove, Shuffle, Sort, Sortwith methods; Dim, Redim statements; UBound function; Arrays concept