This documentation is archived and is not being maintained.

How to: Put a Value into an Array

You can store one of an array's values by using the array name and the appropriate indexes to specify the individual element.

To put a value into an array element

  1. At the left of the equal sign (=), specify the array name followed by parentheses.

  2. Inside the parentheses, include an expression for each index corresponding to the element you want to store. You need one index for each array dimension. The following example shows some statements that store values in arrays.

    Dim numbers() As Integer

    Dim matrix(,) As Double

    numbers(i + 1) = 0

    matrix(3, j * 2) = j

    For each array dimension, the GetUpperBound method returns the highest value the index can have. The lowest index value is always 0.

Show: