Not a Member Yet,
Click here to Register
How do you like the new design?

ID: 295
Viewed: 2547
Added: Jul 26, 2002
Snippet uploaded by: snippet
Written By: Brad Martinez
Demo: Sorry, no demo

User Rated at: 0 Stars
Rate This:

Thank you for your vote. Please wait...

It appears you already voted for this snippet

It appears your vote value was empty

Searches the specified parent treeview node, and subsequently
all of the parent node's children nodes, for the specified string.
(the Nodes collection is one-based)

nodeParent - parent node's object reference
sTarget - string to search for
Compare - indicates the case sensitivity of the search

Highlight all by clicking in box

Highlight All
Private Function FindTVString(nodeParent As Node, _
sTarget As String, _
Compare As VbCompareMethod) As Integer
Dim nodeChild As Node
Dim wIdx As Integer

' First check the parent node's text
' If found, return it's index and exit.
If InStr(1, nodeParent.Text, sTarget, Compare) Then
FindTVString = nodeParent.Index
Exit Function
End If

' Get the parent node's first child
Set nodeChild = nodeParent.Child

' Now walk through the current parent node's children
Do While Not (nodeChild Is Nothing)

' If the current child node has it's own children...
If nodeChild.Children Then
' Recursively call this proc searching for the target string.
' If found, return the index and exit.
wIdx = FindTVString(nodeChild, sTarget, Compare)
If wIdx Then
FindTVString = wIdx
Exit Function
End If

' Check the current child node's text (it has no children)
' If found, return it's index and exit.
If InStr(1, nodeChild.Text, sTarget, Compare) Then
FindTVString = nodeChild.Index
Exit Function
End If

End If

' Get the current child node's next sibling
Set nodeChild = nodeChild.Next


End Function

No Comments to show

Please completely fill out the form below if you want to review this snippet. All reviews are subject to validation.

Replying to a Comment...

Adding your comment. Please wait...

Thanks for adding your comment!. After further review it will be added.

There was a problem adding your comment. Please try again.

Please complete all the fields in the form before sending.

© 2002 - 2018 All Rights Reserved. Conditions