Avg Method

Microsoft Office InfoPath

Returns a Variant that is the average value of all of the numerical elements in a node set.

expression.Avg(ByVal pxmllistInput As IXMLDOMNodeList) As Variant

expression    Required. An expression that returns a reference to the Math object.

pxmllistInput    Required IXMLDOMNodeList. The node set that contains the values to be averaged.

returns    A Variant that represents the average value of all the numerical elements in a node set.

Security

0: Can be accessed without restrictions.

Remarks

Note  This object model member is not supported when the Disable Service Pack features option on the Advanced tab of the Options dialog box in InfoPath is selected or when Microsoft Office 2003 Service Pack 1 or later is not installed. Any form that implements this object model member in its code will generate an error message if it is opened in InfoPath when service pack features are disabled or unavailable.

Example

In the following example, the variable averageAge is set to the average value of all of the numerical elements in the my:ages node set.

var ages = XDocument.DOM.selectNodes("//my:ages");
var averageAge = XDocument.Util.Math.Avg(ages);