Community articleGetChildren function
Added by IBM contributorIBM on May 2, 2012
Rate this article 1 starsRate this article 2 starsRate this article 3 starsRate this article 4 starsRate this article 5 stars

No abstract provided.


This function, along with GetParent, is used to traverse vertically along the form hierarchy. GetChildren returns the first child of the indicated node. If the node has no children, null is returned. All child nodes of a IFormNodeP can be traversed using a while loop in combination with GetNext.


Function GetChildren() As IFormNodeP


There are no parameters for this function.


The IFormNodeP that represents the child or null if no child exists.


The following sample function receives any form node and returns a reference to the last page of the form. First, the function uses GetNodeType to determine if the supplied node is a the form level. If so, the function uses GetChildren to locate the first page node. If not, the function uses GetParent to locate a page level node. The function then uses GetNext to locate the last page in the form and calls GetReferenceEx to retrieve a reference to that node.
   Function GetLastPage(Node)
      Dim MainNode, TestNode ' objects
      Set MainNode = Node
      ' Locate the page level node that is the nearest ancestor or child of
      ' the current node.  If the node is a form node, get the child.  If the
      ' node is any other type, get the parent until a page node is 
      ' retrieved.
      If MainNode.getNodeType = UFL_FORM Then 
         Set MainNode = MainNode.GetChildren
         ' Locate the page node of the form by iterating through the parents
         ' of the supplied node.  At the end of this loop, MainNode will be
         ' a page node.
         Do While (Not(MainNode.GetNodeType = UFL_PAGE))
            Set MainNode = MainNode.GetParent
      End If
      ' Set TestNode to be the MainNode (the page node) before beginning the
      ' next loop.
      Set TestNode = MainNode
      ' Locate the last page node by iterating through the siblings of the
      ' global page node.  At the end of this loop, TestNode will be Nothing
      ' and MainNode will be the last page node.
      Do While (Not(TestNode Is Nothing))
         Set MainNode = TestNode
         Set TestNode = TestNode.GetNext
      ' Get a reference to the MainNode and return that reference to the
      ' caller.
      GetLastPage = MainNode.GetReferenceEx(vbNullString, Nothing, Nothing,_
   End Function

Parent topic:
FormNodeP functions