Solved

Create File of files in a folder

Posted on 1998-08-22
1
135 Views
Last Modified: 2010-04-30
How can I create a file that contains a listing of all of the files with a .dat extension?  Using vb on windows95.
0
Comment
Question by:Lee5
1 Comment
 

Accepted Solution

by:
fc_hnat earned 50 total points
Comment Utility
Try this Lee5.
This
Private Sub Command1_Click()
   
    On Error GoTo ErrorHandler
     
    For x = 67 To 90
        Drive = Chr(x) & ":"
        ChDrive (Drive)
    Open "F:\MyFile" & Chr(x) & ".txt" For Output As #1
        MyFindFiles Drive & "\<path>", "*.*" ' replace path with folder.
    Close 1
10  Next
     
    MsgBox "Done."
     
    Exit Sub
     
ErrorHandler:
    Resume 10

End Sub
Private Sub MyFindFiles(ByVal sPath As String, ByVal sFilePattern As String)
    Dim sFile As String
    Dim coldir() As String
    Dim y As Integer
         
    On Error Resume Next
         
    sFile = Dir$(sPath & sFilePattern)
    While sFile <> ""
        If Left$(sFile, 1) <> "." Then
            Print #1, sPath & sFile
        End If
        sFile = Dir$
    Wend
             
    sFile = Dir$(sPath, 16)
    While sFile <> ""
        If Left$(sFile, 1) <> "." Then
            If GetAttr(sPath & sFile) And 16 Then
                y = y + 1
                ReDim Preserve coldir(y)
                coldir(y) = sPath & sFile & "\"
            End If
        End If
        sFile = Dir$
    Wend
         
    For z = 1 To y
        MyFindFiles coldir(z), sFilePattern
    Next
         
    Erase coldir
    y = 0

End Sub


0

Featured Post

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

This article is the result of a quest to better understand Task Scheduler 2.0 and all the newer objects available in vbscript in this version over  the limited options we had scripting in Task Scheduler 1.0.  As I started my journey of knowledge I f…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now