lstVersions.additem GetFileVersion(results(i))
I get a byref arguement type mismatch...
Whats happening in this code is the program is searching for files and stores the file found in results(i).. I want to get its version, but it wont work. If, however, I put all the found files in a listbox and use a for/next loop, the code
lstVersions.additem GetFileVersion(lstFiles.List(i))
works perfectly.. anyone know why the first code wont work, but the second does?
Heres the code for getfileversion
Code:Public Function GetFileVersion(strFile As String) Dim tempFile As String Dim pos As Long Dim StartPos As Long, EndPos As Long fileText$ = "FileVersion" nextText$ = "InternalName" Open strFile For Binary As #1 tempFile = Space(LOF(1)) Get #1, , tempFile Close #1 pos = InStr(tempFile, NullPad("StringFileInfo")) If pos = 0 Then pos = InStr(tempFile, "StringFileInfo") If pos = 0 Then pos = 1 pnStart = InStr(pos, tempFile, fileText$) fileLength% = 12 Else pnStart = InStr(pos, tempFile, NullPad(fileText$)) fileLength% = 26 End If If pnStart > 0 Then StartPos = pnStart + fileLength% EndPos = InStr(StartPos, tempFile, String(3, Chr(0))) If InStr(Mid(tempFile, StartPos, EndPos - StartPos), nextText$) <> 0 Then For i = 1 To 255 If CInt(Asc(Mid(tempFile, StartPos + i, 1))) <= 31 Then EndPos = StartPos + (i - 1) Exit For End If Next i counter = counter + 1 End If FileInfo = Mid(tempFile, StartPos, EndPos - StartPos) GetFileVersion = ReplaceIt(FileInfo, Chr(0), "") End If End Function




Reply With Quote