Recursion and traversing a treeview – Rest Response viewer

In a previous post I covered how to navigate REST responses using a simple treeview control as well as how to create a Treeview from any jSon object in a few lines of code.

Recursion plays a role in dealing with most kinds of hierarchical linked objects. Here’s how to traverse a treeview.

Looking at the results returned by a Tweet sentiment Rest query to the Excel rest library we can use the Rest Results Explorer to see what came back. Next we want to be able to select which fields we want to transfer to Excel, and this needs some treeView traversal to pass on the status of the applied checkboxes as below.


Private Sub trcJobject_NodeCheck(ByVal node As MSComctlLib.node)
    ' if we get here then a check has been set on on or off..
    ' all the children need to inherit this
    grantParentNodeCheck node, node.Checked
End Sub
Private Sub grantParentNodeCheck(parent As MSComctlLib.node, _
                        Optional check As Boolean = True)
    Dim child As MSComctlLib.node
    parent.Checked = check
    Set child = parent.child
    While Not child Is Nothing
        grantParentNodeCheck child, check
        Set child = child.Next
End Sub

See how to traverse a treeview , getting started with recursion and Recursion deep dive for more details

About brucemcp 225 Articles
I am a Google Developer Expert and decided to investigate Google Apps Script in my spare time. The more I investigated the more content I created so this site is extremely rich. Now, in 2019, a lot of things have disappeared or don’t work anymore due to Google having retired some stuff. I am however leaving things as is and where I came across some deprecated stuff, I have indicated it. I decided to write a book about it and to also create videos to teach developers who want to learn Google Apps Script. If you find the material contained in this site useful, you can support me by buying my books and or videos.