Results 1 to 4 of 4

Thread: Looping...

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Jul 2002
    Posts
    296

    Looping...

    Hey all!

    I need to open a folder, loop through it, grab all the .XFC files, load them into my app, then loop through hte loaded files and do something with each one of them? Anyone know how to do this?
    Kevin Carpenter
    Currently Working in the CAOS (CA Operating System) Group

  2. #2
    Frenzied Member ae_jester's Avatar
    Join Date
    Jun 2001
    Location
    Kitchener Ontario Canada Earth
    Posts
    1,545
    VB Code:
    1. Dim sDirectory As String, sFilename As String, sFilepath As String
    2.     Dim lFilenum As Long
    3.    
    4.     sDirectory = "C:\"
    5.  
    6.     'Get the first matching file
    7.     sFilename = Dir$(sDirectory & "*.xfc")
    8.    
    9.     Do While Len(sFilename) > 0
    10.         sFilepath = sDirectory & sFilename
    11.         lFilenum = FreeFile
    12.        
    13.         'Open the file
    14.         Open sFilepath For Input As #lFilenum
    15.  
    16.         'Now do whatever you want to do with the files
    17.         'bla bla bla
    18.  
    19.         'Close the file
    20.         Close #lFilenum
    21.        
    22.         'Get the next matching file
    23.         sFilename = Dir$
    24.     Loop

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Jul 2002
    Posts
    296
    How do I get the text into a variable? Thanks.
    Kevin Carpenter
    Currently Working in the CAOS (CA Operating System) Group

  4. #4
    VB6, XHTML & CSS hobbyist Merri's Avatar
    Join Date
    Oct 2002
    Location
    Finland
    Posts
    6,654
    VB Code:
    1. 'Open the file
    2.         Open sFilepath For Input As #lFilenum
    3.  
    4.         'Read stuff into Buffer
    5.         Buffer = Input(LOF(lFilenum), lFilenum)
    6.  
    7.         'Now do whatever you want to do with the files
    8.         'bla bla bla
    9.  
    10.         'Close the file
    11.         Close #lFilenum

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