Results 1 to 13 of 13

Thread: [RESOLVED] Trouble opening files

Threaded View

  1. #4
    PowerPoster
    Join Date
    Jul 2006
    Location
    Maldon, Essex. UK
    Posts
    6,334

    Re: Trouble opening files

    This code is in the Form_Load event. On Form Load, File1.FileName will be null. (Assuming that File1 is a FileListBox)

    You either need to select the Customer'th item before trying to open it in order to set the value of the Filename property.
    Code:
    File1.Selected(Customer) = True
    This will highlight the file being processed in the FileListBox as it goes through each one

    or use:

    Code:
    Open (File1.Path & "\" & File1.List(Customer)) For Input As #1
    instead, which will not highlight anything in the FileListBox. I think I'd also set the FileListBox's Enabled property to False so the user is aware that the process is 'automatic' and can't click on an entry, which might mess your loop up if you use the first option above.

    BTW It's good practice to use FreeFile to get a File Number rather than assume #1 is available.
    Code:
    Din InfFile as Integer
    intFile = FreeFile
    Open .....etc..... As Intfile.
    .
    . etc
    .
    Input #intFile ,CusData(i)
    Last edited by Doogle; Jul 3rd, 2011 at 03:53 AM. Reason: Modified answer to match question properly

Tags for this Thread

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