Community articleGetNodeType function
Added by IBM contributorIBM on July 26, 2013
Rate this article 1 starsRate this article 2 starsRate this article 3 starsRate this article 4 starsRate this article 5 stars


This function returns the type for a node (for example, page, item, option, and array). This allows you to quickly determine the type of node you are working with and what depth you are at in the node hierarchy.


   Function GetNodeType( ) As Long


There are no parameters for this function.


One of the following types:
  • UFL_FORM — The root node of the form.
  • UFL_PAGE — A page level node.
  • UFL_ITEM — An item level node.
  • UFL_OPTION — An option level node.
  • UFL_ARRAY — An argument level node, such as an array element.
This function throws an exception if an error occurs.


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