Hello, I'm using the code below to check how many valid avi videos there are in a folder.

Every time a valid avi video has been found, 1 should be counted up (ct). This works fine if there are only valid avi videos in the folder, but if I rename a mp3 audio file to .avi and put that file in the folder with the valid avi videos, then ct always returns "0".

Does anybody know what is wrong?

VB Code:
  1. Public Function GetFileType(xFile As String) As String
  2.     On Error Resume Next
  3.     Dim ID As String * 300
  4.  
  5.     Open xFile For Binary Access Read As #1
  6.     Get #1, 1, ID
  7.     Close #1
  8.     GetFileType = Mid(ID, 9, 8)
  9. End Function
  10.  
  11.  
  12.  
  13. Private Sub cmdCheck_Click()
  14.   Dim ct As Integer
  15.   Dim a As String
  16.   Dim Valid_type As String
  17.  
  18.   ct = 0
  19.   a = sPath & Dir(sPath & "*.avi")
  20.   Valid_type = GetFileType(a)
  21.  
  22.   Do While LenB(a) > LenB(sPath)
  23.    
  24.     If Valid_type = "AVI LIST" Then
  25.     ct = ct + 1
  26.     End If
  27.    
  28.     a = sPath & Dir
  29.   Loop
  30.  
  31. Msgbox ct
  32.  
  33. End Sub