Sub txtSearch_TextChanged (Old As String, New As String)
'Search Function, every time a new letter is put in the text box we will search the Database and Display the matching items
Dim Cursor1 As Cursor
Select TabHost1.CurrentTab
Case 0
lvArtist.Clear '
Cursor1 = SQL1.ExecQuery("SELECT DISTINCT artist FROM main WHERE artist LIKE '%" & New & "%' ORDER BY 'artist';")
For i = 0 To Cursor1.RowCount - 1
Cursor1.Position = i
lvArtist.AddSingleLine(Cursor1.GetString("artist"))
Next
lvArtist.Invalidate
Case 1
Dim Bitmap1 As Bitmap
Dim BitmapEmpty As Bitmap
Bitmap1.Initialize(File.DirAssets, "Star2.png")
BitmapEmpty.Initialize(File.DirAssets, "Empty100x100.png")
'This moves the Bitmap to the Right side of the screen
lvSongs.TwoLinesAndBitmap.ImageView.Left = lvSongs.Width - (Bitmap1.Width / 1.5)
lvSongs.TwoLinesAndBitmap.Label.Left = 0
lvSongs.TwoLinesAndBitmap.SecondLabel.Left = 0
lvSongs.Clear 'SQL1.ExecNonQuery("CREATE TABLE main (artist TEXT, title TEXT, fav INTEGER)")
If CurrentArtist = "" Then
Cursor1 = SQL1.ExecQuery("SELECT DISTINCT * FROM main WHERE title LIKE '%" & New & "%' ORDER BY title;")
Else
Cursor1 = SQL1.ExecQuery("SELECT DISTINCT * FROM main WHERE artist = " & QUOTE & CurrentArtist & QUOTE & " AND title LIKE '%" & New & "%' ORDER BY title;")
End If
For i = 0 To Cursor1.RowCount - 1
Cursor1.Position = i
If Cursor1.GetInt("fav") = 0 Then
lvSongs.AddTwoLinesAndBitmap(Cursor1.GetString("title"), cursor1.GetString("artist"), BitmapEmpty)
Else
lvSongs.AddTwoLinesAndBitmap(Cursor1.GetString("title"), cursor1.GetString("artist"), Bitmap1)
End If
Next
lvSongs.Invalidate
Case 2
lvFavorites.Clear 'SQL1.ExecNonQuery("CREATE TABLE main (artist TEXT, title TEXT, fav INTEGER)")
Cursor1 = SQL1.ExecQuery("SELECT DISTINCT * FROM main WHERE fav = '1' AND title LIKE '%" & New & "%' ORDER BY title;")
For i = 0 To Cursor1.RowCount - 1
Cursor1.Position = i
lvFavorites.AddTwoLines(Cursor1.GetString("title"), cursor1.GetString("artist"))
Next
lvFavorites.Invalidate
Case Else
End Select
InSearchMode = New
Cursor1.Close
End Sub