Compartilhar via


Como: Alterar uma matriz para uma matriz diferente (Visual Basic)

It is important to distinguish between an array object and an array variable. An array variable holds a pointer to an array object, which holds the array elements and the rank and length information.

  • Once you create an array object, you cannot change its rank (number of dimensions), its dimension lengths, or the data type of its elements. You can change only the contents of its elements.

  • Once you declare an array variable, you cannot change its rank or its element data type. However, you can assign a succession of different array objects to the variable during its lifetime. These array objects can have different dimension lengths.

To change an array variable to point to a different array object

  • Use a standard assignment statement to assign the source array to the destination array.

    Dim array1(4), array2(19) As String
    array2 = array1
    

You can change an array variable to point to an array object with different dimension lengths, but you cannot change it to point to an array object of a different data type. This means that the rank and the element data type must remain the same, because they are inherently part of the array variable's data type.

Consulte também

Tarefas

Como: Inicializar variáveis de matriz no Visual Basic

Como: Ceder uma matriz a outra matriz (Visual Basic)

Como: Passar uma matriz para um procedimento ou propriedade (Visual Basic)

Como: Retornar uma matriz de um procedimento ou propriedade (Visual Basic)

Solucionando problemas de matrizes (Visual Basic)

Conceitos

Matrizes no Visual Basic