Click to See Complete Forum and Search --> : Trouble with TreeView Control (VB6)


Cousin Sammy
August 23rd, 2001, 04:50 PM
I am attempting to use indeces to go through all the nodes in a TreeView, and save the data. I figured since you could use them to remove nodes, you could refer to the nodes that way as well -- I was wrong.
*Notes about code:
-GetIndex takes the text of a given node and asigns to the varible "gottenIndex", the index of the entry of the collection memList, whose "sName" property matches the text of the node. memList is a collection of clsMembers, a Class I wrote, that has fName, lName, sName, Notes, Rank, and Superior.
Here is the Save code I'm using:


Public Sub Save_Data()
Open "C:\test.txt" For Output As #1
For i = 1 To MemList.Count
GetIndex (frmMain.tvTreeView(i).Text) ' won't work b/c TreeView doesn't take an index unless it's trying to remove an item
Select Case MemList(gottenIndex).Rank
Case "King":
Write #1, frmMain.tvTreeView(i).sName
Case "Governor":
Write #1, vbTab & frmMain.tvTreeView(i).sName
Case "Officer":
Write #1, vbTab & vbTab & frmMain.tvTreeView(i).sName
Case "Countryman":
Write #1, vbTab & vbTab & vbTab & frmMain.tvTreeView(i).sName
End Select
Next i
Write #1, "//"
For i = 1 To MemList.Count
Write #1, MemList(i).fName, MemList(i).lName, MemList(i).sName, MemList(i).Notes, MemList(i).Rank, MemList(i).Superior
Next i
Close #1
End Sub


The output should look something like this( sans the "=" signs:
=================================
Joe
Tom
Harry
Pete
//
First,Last,Joe,Notes,King,
First,Last,Tom,Notes,King,
First,Last,Harry,Notes,Governor,Tom
First,Last,Pete,Notes,Governor,Tom
====================================
Hope you can help...

Thanks in advance,
Pete "Cousin Sammy" Michaud

Cousin Sammy
August 23rd, 2001, 05:10 PM
Notes about that file format:

Joe
Tom
Harry 'this should be tabbed
Pete 'this should be tabbed
//
First,Last,Joe,Notes,King,
First,Last,Tom,Notes,King,
First,Last,Harry,Notes,Governor,Tom
First,Last,Pete,Notes,Governor,Tom