Is this possible...
I need to open several files as binary, the names of which are defined by the user at runtime and placed in a listbox. Can this be done??? How???:confused:
Thanks in advance for any help!
~Squirrelly1:D
Printable View
Is this possible...
I need to open several files as binary, the names of which are defined by the user at runtime and placed in a listbox. Can this be done??? How???:confused:
Thanks in advance for any help!
~Squirrelly1:D
Sure it can be done, try something like this.
Code:'Opens all the files at the same time
for i=0 to me.listbox1.listcount-1
Open me.listbox1.list(i) for binary as #1
'Do something to the file
Close #1
next i
There is a limit to the total number of files open at one time.Code:dim File() as integer
sub Openlist()
On Erroro Goto Bottom
for =i 0 to List1.ListCount - 1
redim preserve File(i+1)
File(i+1 ) = i+1
open list1.list(i) for binary access read as File(i+1)
next
Exit Sub
Bottom:
msgbox "Error opening " & list1.List(i),vbOkonly
Ok, here goes... I entered this code:
And got a 'Bad File Name or Number' error...Code:For i = 0 To Me.List1.ListCount
Open Me.List1.List(i) For Binary Access Read Write Lock Write As intFreeFile
ReDim bytAll(LOF(intFreeFile) - 1)
Get intFreeFile, , bytAll
Close intFreeFile
Next i
An example of this file name is "C:\My Documents\My Pictures\Picture.bmp" And If I open a design time specified *.bmp file under the same circumstances, it works fine!!!
Sure, you say "This is no problem", but I'm pulling my hair out! Thanx for any help!
Squirrelly1 or in this case: Confused1:confused: ;)
How do get intFreeFile, and what is the value of me.list1.list(0). Try this:
Code:For i = 0 To Me.List1.ListCount
debug.print me.list1.list(i)
Open Me.List1.List(i) For Binary Access Read Write Lock Write As intFreeFile
ReDim bytAll(LOF(intFreeFile) - 1)
Get intFreeFile, , bytAll
Close intFreeFile
Next i
AIS_DK,
Thanx for mentioning the FileNumber!!! After reading your reply I got to thinking and I realized that I accidentally deleted my:
which made a world of difference!Code:intFreeFile = FreeFile
THanx again,
Squirrelly1:p