Returns a new matrix object that represents the result of the multiplication of the current matrix by another matrix.
MatrixObject.Times(Matrix2)
A matrix object reference that contains the result of matrix multiplication.
Error 1307 is returned if the number of rows of the Matrix2 is not equal to number of columns of the current matrix.
Private Sub MatrixInverse()
Dim A As Matrix, B As Matrix, C As Matrix
'Generate a matrix, fill it with random values
'and print it in debug window
Set A = New Matrix
A.Size 5, 5
A.FillRandom
Debug.Print "Matrix A = "
Debug.Print A.GetString
'Use Inverse method to get its inverse
On Error Resume Next
Set B = A.Inverse
If (Err.Number = (vbObjectError + 1306)) Then
Debug.Print "Matrix is singular"
Exit Sub
End If
On Error GoTo 0
Debug.Print "Matrix B = A.Inverse"
Debug.Print B.GetString
'Now verify the result by forming the product
' C = A x B. Matrix C is a unary matrix
Set C = A.Times(B)
Debug.Print "C = A x B "
Debug.Print C.GetString
End Sub
Matrix A = | 6.000 2.000 8.000 6.000 5.000 | | 4.000 9.000 8.000 7.000 2.000 | | 9.000 7.000 5.000 3.000 0.000 | | 1.000 4.000 1.000 2.000 10.000 | | 4.000 1.000 0.000 0.000 4.000 | Matrix B = A.Inverse | -0.048 0.176 -0.158 -0.235 0.560 | | -0.076 -0.069 0.198 0.174 -0.305 | | 0.410 -1.035 1.032 0.847 -2.112 | | -0.362 1.360 -1.374 -1.112 2.552 | | 0.067 -0.158 0.108 0.192 -0.233 | C = A x B | 1.000 0.000 0.000 0.000 0.000 | | 0.000 1.000 0.000 0.000 0.000 | | 0.000 0.000 1.000 0.000 0.000 | | 0.000 0.000 0.000 1.000 0.000 | | 0.000 0.000 0.000 0.000 1.000 |