Returns / sets all elements of a matrix object to / from an array.
MatrixObject.AsArray = ValArray ValArray = MatrixObject.AsArray
Read / write. The value is an array of type Double containing all matrix elements.
The AsArray property can be used to quickly assign all elements of a Matrix object to elements of an array, and vice versa. This is much simpler and faster than explicitly setting each element.
When using AsArray property from within Visual Basic, declare the arrays your are going to use as dynamic arrays:
Dim ValArray() as Double
Dim ValArray(5,5) as Double
Error 1304 is returned if ValArray parameter is not zero based or it is of incorrect type.
The following code example demonstrates the use of the AsArray Property.
Private Sub MatrixAsArray() Dim A As Matrix Dim B() as Double Set A = New Matrix A.Size 3,3 A(0, 0) = 1: A(0, 1) = 2: A(0, 2) = 1 A(1, 0) = 2: A(1, 1) = 3: A(1, 2) = 4 A(2, 0) = 3: A(2, 1) = 2: A(2, 2) = 1 B = A.AsArray 'Array B now contains all elements of Matrix A 'We change some values of array B B(0, 0) = 5: B(2, 0) = 7: B(1, 1) = 10 'and then assign the whole array to the matrix A.AsArray = B End Sub
Applies To: Matrix