19-02-13, 04:56 PM
السلام عليكم ورحمة الله وبركاته
أخي الكريم هذه طريقة لجلب المفاتيح والقيم ولكن عن طريق الكود تستطيع الاستفادة منها إلى جانب دوال API
لكي يعمل الكود ضع أداة زر Button1
وثلاث أدوات ListBox
ثم ضع الكود التالي
بالتوفيق
أخي الكريم هذه طريقة لجلب المفاتيح والقيم ولكن عن طريق الكود تستطيع الاستفادة منها إلى جانب دوال API
لكي يعمل الكود ضع أداة زر Button1
وثلاث أدوات ListBox
ثم ضع الكود التالي
كود :
Dim filename As String = Application.StartupPath & "\Settings.ini"
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
ListBox1.Items.Clear()
Dim Lines() As String = System.IO.File.ReadAllLines(filename, System.Text.Encoding.Default)
Dim Keys = From Line In Lines Where Line.StartsWith("[") = True Select Line.Substring(1, Line.IndexOf("]") - 1)
For Each Key In Keys
ListBox1.Items.Add(Key)
Next
End Sub
Private Sub ListBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ListBox1.SelectedIndexChanged
ListBox2.Items.Clear()
ListBox3.Items.Clear()
Try
Dim Lines() As String = System.IO.File.ReadAllLines(filename, System.Text.Encoding.Default)
Dim KeyIndex As Integer = Array.IndexOf(Lines, "[" & ListBox1.SelectedItem & "]") + 1
Dim KeyNext As Integer = Lines.Count - 1
If ListBox1.SelectedIndex < ListBox1.Items.Count - 1 Then
KeyNext = Array.IndexOf(Lines, "[" & ListBox1.Items.Item(ListBox1.SelectedIndex + 1) & "]") - 1
End If
For I = KeyIndex To KeyNext
ListBox2.Items.Add(Lines(I).Split("=")(0))
Next
Catch ex As Exception
End Try
End Sub
Private Sub ListBox2_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ListBox2.SelectedIndexChanged
ListBox3.Items.Clear()
Try
Dim Lines() As String = System.IO.File.ReadAllLines(filename, System.Text.Encoding.Default)
Dim KeyIndex As Integer = Array.IndexOf(Lines, "[" & ListBox1.SelectedItem & "]") + 1
Dim KeyNext As Integer = Lines.Count - 1
If ListBox1.SelectedIndex < ListBox1.Items.Count - 1 Then
KeyNext = Array.IndexOf(Lines, "[" & ListBox1.Items.Item(ListBox1.SelectedIndex + 1) & "]") - 1
End If
For I = KeyIndex To KeyNext
If Lines(I).StartsWith(ListBox2.SelectedItem) = True Then
ListBox3.Items.Add(Lines(I).Split("=")(1))
End If
Next
Catch ex As Exception
End Try
End Subبالتوفيق

