Hi guys.

im using a media player control to access WMP library

I need to search the library, for song title, artist and album.

all going well so far, as long as i get a dead on match...


is there any way to make it find a close match - such as that in media player itself... [ie: Rock will find Rock Ferry, Rock a by baby, ETC]

i have tried the % and * wild cards, but doesnt help. CHEERS!

i have 3 option selects [name, artist, album], 1 command button, and the wmp on my form.... and...
Ive got the following code:

vbcode Code:
  1. Dim CurSong As IWMPMedia
  2. Dim medcol As IWMPPlaylist
  3.  
  4. Dim iSearch As Integer
  5.  
  6.  
  7. Private Sub cmdSearch_Click()
  8.  
  9.  
  10.     Dim sSearch As String: sSearch = InputBox("Enter term to search:")
  11.  
  12.     Select Case iSearch
  13.         Case 0:
  14.             Set medcol = wmp.mediaCollection.getByName(sSearch)
  15.            
  16.         Case 1:
  17.             Set medcol = wmp.mediaCollection.getByAuthor(sSearch)
  18.            
  19.         Case 2:
  20.             Set medcol = wmp.mediaCollection.getByAlbum(sSearch)
  21.    
  22.     End Select
  23.    
  24.  
  25.  
  26.     Debug.Print medcol.Count
  27.  
  28.     Dim i As Integer
  29.    
  30.     Dim sFilepath As String, iMediaCount As Integer
  31.     iMediaCount = 0
  32.    
  33.    
  34.    
  35.     For i = 0 To medcol.Count - 1
  36.    
  37.         sFilepath = medcol.Item(CLng(i)).sourceURL
  38.        
  39.         If Right$(sFilepath, 4) <> ".wpl" Then
  40.        
  41.             Debug.Print i & " - " & medcol.Item(CLng(i)).Name & ": " & sFilepath
  42.             iMediaCount = iMediaCount + 1
  43.            
  44.             ' play the last song found...
  45.             If i = medcol.Count - 1 Then
  46.                 Set CurSong = wmp.newMedia(sFilepath)
  47.                 wmp.currentMedia = CurSong
  48.             End If
  49.            
  50.         Else
  51.             Debug.Print i & "..."
  52.         End If
  53.        
  54.         DoEvents
  55.        
  56.        
  57.     Next i
  58.    
  59.     Debug.Print "Useful media files:" & iMediaCount
  60.    
  61.  
  62.  
  63.  
  64. End Sub
  65.  
  66. Private Sub optSearch_Click(Index As Integer)
  67.     iSearch = Index
  68. End Sub