Hi,
thanks to LaVolpe which sent me a great code to search the treeview I have another short question.
Can you take a look at the code, and tell me is there any possible to stop the searching if program will find node.text = STOP? after one click if TEST node has been found.
My treeview contains "the chapters" - groups of the nodes. Each of them has STOP node at the end. I wanna to stop the program if find position will get the last line of the chapter ( equal to STOP node ).
Is there any way?
Code:
My treeview:Code:Public Sub Command5_Click() Dim NrLoops As Integer, iLastItem As Integer, iFirstItem As Integer Dim i As Integer Dim Searcher As String Dim Searcher2 As String Dim FindPos As Integer Dim found As Boolean Searcher = "TEST" iLastItem = TreeView5.Nodes.Count If TreeView5.SelectedItem Is Nothing Then ' start from top iFirstItem = 1 Else iFirstItem = TreeView5.SelectedItem.Index + 1 ' start on row after one selected If iFirstItem > iLastItem Then iFirstItem = 1 ' at bottom of list, start from top End If For NrLoops = 0 To 1 For i = iFirstItem To iLastItem FindPos = InStr(1, TreeView5.Nodes(i).Text, Searcher, vbTextCompare) If FindPos <> 0 Then TreeView5.SetFocus Set TreeView5.SelectedItem = TreeView5.Nodes(i) TreeView5.SelectedItem.EnsureVisible found = True ' no longer needed. If FindPos=0 then found=false Exit For End If Next i If FindPos = 0 Then iLastItem = iFirstItem - 1 iFirstItem = 1 Else Exit For End If Next NrLoops If FindPos = 0 Then MsgBox ("Not found") End Sub
![]()


Reply With Quote
