Private Sub txtSearch_KeyPress(sender As Object, e As KeyPressEventArgs) Handles txtSearch.KeyPress

 

Dim RecipeTitle As String = ""

Dim WholeRecipe As String = ""

Dim Found As Integer

 

If Asc(e.KeyChar) = Keys.Enter Then

 

lstTitles.Items.Clear()

 

Dim reader As New Xml.XmlNodeReader(doc)

 

While reader.Read()

 

If reader.Name = "title" Then

RecipeTitle = reader.ReadElementContentAsString

WholeRecipe = RecipeTitle & " " & reader.ReadElementContentAsString

End If

 

 

If InStr(LCase(WholeRecipe), LCase(txtSearch.Text)) Then

 

lstTitles.Items.Add(RecipeTitle)

found = True

RecipeTitle = ""

WholeRecipe = ""

End If

 

End While

 

 

If found = True Then

lstTitles.SelectedIndex = 0

Call lstTitles_Click(Me, e)

lstTitles.BackColor = Color.CornflowerBlue

Else

btnShowAllTitles_Click(Me, e)

MsgBox("Nothing matched your search term " & txtSearch.Text)

End If

 

End If

 

End Sub