Share via


How to: Get a Value from an Array 

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

To get a value from an array element

  1. Inside an expression, specify the array name followed by parentheses.

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

    Dim sortedValues(), rawValues(), estimates(,,) As Double
    lowestValue = sortedValues(0)
    wTotal += (rawValues(v) ^ 2)
    firstGuess = estimates(i, j, k)
    

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

See Also

Tasks

How to: Declare an Array Variable
How to: Create an Array
How to: Initialize an Array Variable
How to: Put a Value into an Array
How to: Locate an Element in an Array in Visual Basic
How to: Reverse the Contents of An Array in Visual Basic
How to: Sort An Array in Visual Basic
Troubleshooting Arrays

Concepts

Array Dimensions in Visual Basic

Other Resources

Arrays in Visual Basic