home *** CD-ROM | disk | FTP | other *** search
-
- Private Sub lstFileContents_Click()
-
- Dim intEqualPos As Integer
- Dim lonListPtr As Long
- Dim strListItem As String
-
- txtKeyName.Text = ""
- txtValue.Text = ""
-
- ' Get the item that was chosen from the list box.
- strListItem = lstFileContents.List(lstFileContents.ListIndex)
-
- ' Did the user click on a section name (enclosed in
- ' brackets) or a key name?
- If Left$(LTrim$(strListItem), 1) = "[" Then
- txtSectionName.Text = strListItem
- Else
- txtSectionName.Text = ""
- ' Separate the key info into the key name and
- ' its value.
- intEqualPos = InStr(strListItem, "=")
- If intEqualPos > 1 Then
- txtKeyName.Text = Left$(strListItem, intEqualPos - 1)
- txtValue.Text = Mid$(strListItem, intEqualPos + 1)
- End If
- ' Loop backwards through the list and try to
- ' find the section name to which the key belongs.
- For lonListPtr = lstFileContents.ListIndex To 0 Step -1
- strListItem = LTrim$(lstFileContents.List(lonListPtr))
- If Left$(strListItem, 1) = "[" Then
- txtSectionName.Text = strListItem
- Exit For
- End If
- Next lonListPtr
- End If
-
- End Sub
-