I am severely confused while trying to do some thing like this with treeview. Need help please... I am trying to populate an treeview by reading lines from an text file.
The text file contains the paths of the in the format below
I am trying to make the treeview using the paths as above with the top node as TOPROOT and the child node as NULL. When the program I have written reads the third line which is repeated again the program quits with an error "key not unique". Unfortunately I cannot prevent the lines in the text file from duplicating as this output is generated by another program.
It would be great if any one can give me some logic as to create the tree structure reading the paths mentioned in the text file.
Thanks in advance...
The code i am trying till now...
The Code Till Now Code:
Dim Filenum As Integer
Dim Temp As String
Dim Arr() As String
Dim x As Long
Dim k As Integer
Dim nodx As Node
Filenum = FreeFile
Open App.Path & "\test.txt" For Input As #Filenum
Do Until EOF(Filenum) = True
Line Input #Filenum, Temp
If Left$(Temp, 1) = "[" Then
Arr() = Split(Replace(Replace(Temp, "[", vbNullString), "]", vbNullString), "\")
If UBound(Arr) = 0 Then
Set nodx = Tv1.Nodes.Add(, , Arr(0), Arr(0))
nodx.Expanded = True
For k = 0 To UBound(Arr)
If k > 0 Then
Set nodx = Tv1.Nodes.Add(Arr(k - 1), tvwChild, Arr(k), Arr(k))
' Set nodx = Tv1.Nodes.Add(Arr(0), tvwChild, Arr(k), Arr(k))
x = x + 1