I am working on VBA. I am selecting a Board file loading the data into treeview(Here Busname as Parent and Net Name as Child nodes)simultaniously I am tracking the duplicates(Netnames) and loading the duplicates into Listview control,Now i need display the duplicates in Treeview itselef.I am Posting the code,List view have 4 lines code.I need to replace this Listbox code with Treeviecode
Private Sub cmdSelectFile_Click()
Temp = ClearContents()
Temp = ColumnHeader()
txtFilePath.Text = Application.GetOpenFilename(FileFilter:="Board Files (*.brd), *.brd", Title:="Please select a Board file")
dummy = GetNetNameAndFillTree()
End Sub
'-------------------------
Private Function GetNetNameAndFillTree()
'imgProcessing.Visible = True
treeBusNode.Nodes.Clear
Dim DuplicateNetName As Boolean
Dim strNetName As String
DuplicateNetName = False
lstNetName.Clear
FullFileName = ActiveWorkbook.Path & "\" & "NetName.txt"
Set objReport = New Report
If CheckBox1.Value = False Then
If Len(Dir(FullFileName)) > 0 Then
Kill (FullFileName)
End If
strTemp = "cmd /c extracta " & Chr(34) & txtFilePath.Text & Chr(34) & " " & Chr(34) & ActiveWorkbook.Path & "\" & "CommandTemplate.txt" & Chr(34) & " " & Chr(34) & ActiveWorkbook.Path & "\" & "NetName.txt" & Chr(34)
Temp = Shell(strTemp, vbHide)
Application.Wait DateAdd("s", 5, Now)
End If
strFileContent = objReport.GetReport(ActiveWorkbook.Path & "\" & "NetName.txt")
myArray = Split(strFileContent, vbCrLf)
myArrayLength = UBound(myArray) - LBound(myArray) + 1
strTemp = ""
DuplicateNetName = False
For i = 0 To myArrayLength - 1 Step 1
If myArray(i) <> "" And Mid(myArray(i), 1, 2) = "S!" Then
strNetName = Split(myArray(i), "!")(1)
If strTemp <> strNetName And strNetName <> "" Then
'----------------------------ListView Code Starts from here--------------------------------
(Please not for your reference Listbox Name is lstNetName)
For j = 0 To lstNetName.ListCount - 1
If lstNetName.List(j) = strNetName Then
DuplicateNetName = True
End If
Next j
If DuplicateNetName = False Then
lstNetName.AddItem (Split(myArray(i), "!")(1))
'-------------------------------------------------------------------------------------------------------------------------------
treeBusNode.Nodes.Add Key:=CStr(Split(myArray(i), "!")(1)) & "_Key", Text:=CStr(Split(myArray(i), "!")(1))
UpdateTree (Split(myArray(i), "!")(1))
strTemp = Split(myArray(i), "!")(1)
End If
DuplicateNetName = False
End If
End If
Next i
'imgProcessing.Visible = False
End Function
. |