cfg file to start, this is the file:
What I am doing is looking for a class, once found I store the data for THAT class in a listbox, so ex: if I'm looking for "Fixing", I will store each line in a listbox that is after "{Fixing}" until we hit the next class OR the end of the file (for Fixing we would stop at "{Pillars}")
Here is my code:
Private Sub tvList_AfterSelect(sender As Object, e As TreeViewEventArgs) Handles tvList.AfterSelect
Dim cfgData() As String
' Dim lstData As New ListBox()
lstData.Items.Clear()
If rbnInch.Checked Then
cfgData = File.ReadAllLines("C:\Library\Common\PARAM-NG\Dbs\Mould\Dme_I\Dme_I.cfg")
Else
cfgData = File.ReadAllLines("C:\Library\Common\PARAM-NG\Dbs\Mould\Dme\Dme.cfg")
End If
Dim classID As Short = tvList.SelectedNode.Index
Dim classType As String = tvList.Nodes.Item(classID).Text
Try
For i As Short = 0 To cfgData.Count - 1
If cfgData(i).Contains("{" & classType & "}") Or cfgData(i).Contains("{" & classType.Replace(" ", "") & "}") Then
i += 1
Do
lstData.Items.Add(cfgData(i))
i += 1
If cfgData(i).Contains(tvList.Nodes.Item(tvList.SelectedNode.Index + 1).Text.Replace(" ", "")) Or cfgData(i).Contains(tvList.Nodes.Item(tvList.SelectedNode.Index + 1).Text) Or cfgData(i).ToString() Is vbNullString Then
Exit Do
End If
Loop
End If
Next
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Sub
Right now I am only getting the first line in my listbox and that's it. Need help on collecting the data I need and then stopping at the next class or end of file (end of file for the last class since there is no class after it that will mark my exit)