- Create a new project in VB6
- Add a form (this will probably happen by default, anyway)
- Pull down the Project menu and choose References.
- Find Microsoft Scripting Runtime and fill in the checkbox to select it. Click OK.
- Add a ListBox control to the form - name will be List1.
- Add a command button to the form - name will be Command1.
- Double-click on the command button to bring up the Click event procedure.
- Paste in the following code...
Expand|Select|Wrap|Line Numbers- Dim fso As New FileSystemObject
- Dim fld As Folder
- Dim fil As File
- Set fld = fso.GetFolder("C:\Temp")
- For Each fil In fld.Files
- List1.AddItem fil.Name
- Next
- Set fil = Nothing
- Set fld = Nothing
- Set fso = Nothing
- Modify such details as the directory (C:\Temp) if required.
- Compile and run.
- Click the command button to fill the listbox with the names of the files in the specified directory.