SetElement Method

The SetElement method sets the value of a specified matrix element.

objMC.SetElement (Row As Long, Col as Long, Value As Variant)

Element

Description

objMC

The Mathcad Matrix object.

Row

Zero-based row index of the element being set.

Col

Zero-based column index of the element being set.

Value

The new element value.

Remarks

This method returns no meaningful result.

If either Row or Col is larger than the current bounds of the matrix, the matrix will be enlarged appropriately. Therefore, when populating a new matrix, it will be most efficient to set elements at the highest indeces first, so that the matrix is immediately allocated to the largest necessary size, as in the following example:

The SetElement method can return an error if you specify an invalid index.

If you have a vector or matrix value, you can pass the entire object using SetValue.