|
-
Apr 28th, 2001, 10:44 PM
#1
Thread Starter
Frenzied Member
Why wont this work!!?
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
-
Apr 28th, 2001, 11:21 PM
#2
Hyperactive Member
The error will be based on the type declaration for results() - is it explicitly declared as a string ?? If it is not - that is probably your problem. A way around this is to use the ByVal keyword in the function:
Code:
Public Function GetFileVersion(ByVal strFile As String)
The above will get rid of your error.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|