Results 1 to 11 of 11

Thread: Newbie Treeview Remove Nodes Question

Threaded View

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Feb 2003
    Posts
    146

    Newbie Treeview Remove Nodes Question

    In my treeview, I'm trying to loop through and remove all the nodes that don't have children. I found some code which seemed to work for the folks on the thread, but I can't get it to work with mine. It keeps stopping on the Remove line, saying "Invalid Key." I've found a couple of explanations with other scenarios for the "Invalid key" message but I'm too much of a newb to fix it as it relates to what I'm trying to do. Can anyone explain it in a little detail what I need to do to fix it?

    Here is the code:

    Code:
     Dim x As Node, y() As Node: ReDim y(0)
        For Each x In Tree1.Nodes
            If x.Child Is Nothing Then
                Set y(UBound(y)) = x
                ReDim Preserve y(UBound(y) + 1)
            End If
        Next
        
        Dim i As Long
        For i = 0 To UBound(y) - 1
            Tree1.Nodes.Remove y
        Next
    Thanks

    EDIT: Thanks Bruce
    Last edited by pinkclown; Jan 5th, 2004 at 01:55 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width