Results 1 to 6 of 6

Thread: How do I...

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Jun 2001
    Location
    USA
    Posts
    1,026

    How do I...

    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???

    Thanks in advance for any help!
    ~Squirrelly1

  2. #2
    AIS_DK
    Guest
    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

  3. #3
    jim mcnamara
    Guest
    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
    There is a limit to the total number of files open at one time.

  4. #4

    Thread Starter
    Frenzied Member
    Join Date
    Jun 2001
    Location
    USA
    Posts
    1,026

    Exclamation Arg! Another Error!

    Ok, here goes... I entered this code:

    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
    And got a 'Bad File Name or Number' error...
    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

  5. #5
    AIS_DK
    Guest
    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

  6. #6

    Thread Starter
    Frenzied Member
    Join Date
    Jun 2001
    Location
    USA
    Posts
    1,026

    Thank you

    AIS_DK,

    Thanx for mentioning the FileNumber!!! After reading your reply I got to thinking and I realized that I accidentally deleted my:

    Code:
    intFreeFile = FreeFile
    which made a world of difference!

    THanx again,
    Squirrelly1
    Now happily married and still crankin' away at the keyboard. Life is grand for a coder, no?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width