Solved

Grid and File list

Posted on 2000-04-07
3
210 Views
Last Modified: 2010-05-02
I need to populate a grid with a list of files in one directory. How do i go about it?
0
Comment
Question by:eliasis
  • 2
3 Comments
 
LVL 14

Accepted Solution

by:
wsh2 earned 100 total points
Comment Utility
1. Open a New Standard.Exe Project
2. Add a FlexGrid to the form (MSFlexGrid1).
3. Set a reference (Vb Menu -> Project -> Reference) to the "Microsoft Scripting Runtime" (SCRRUN.DLL).
4. Copy and paste the following into your Form1 code window.
5. Change the Directory name to what ever you like.

<----- Code Begin ----->

Private Sub Form_Load()

  xFolderList ("c:\Windows") <---- CHANGE

End Sub

Private Sub xFolderList _
(ByVal strDirectory As String) _

  Dim fsoWork As FileSystemObject
  Dim fsoFolder As Folder
  Dim fsoFile As File
 
  Set fsoWork = CreateObject("Scripting.FileSystemObject")
  Set fsoFolder = fsoWork.GetFolder(strDirectory)
 
  MSFlexGrid1.Clear
  MSFlexGrid1.Cols = 5
  MSFlexGrid1.Rows = 0
  MSFlexGrid1.AddItem ( _
    "Line" & vbTab & _
    "Name" & vbTab & _
    "DateCreated" & vbTab & _
    "DateLastAccessed" & vbTab & _
    "DateLastModified" & vbTab)
 
  Dim intLine As Integer
  For Each fsoFile In fsoFolder.Files
    MSFlexGrid1.AddItem ( _
      intLine & vbTab & _
      fsoFile.Name & vbTab & _
      fsoFile.DateCreated & vbTab & _
      fsoFile.DateLastAccessed & vbTab & _
      fsoFile.DateLastModified & vbTab)
  Next fsoFile
 
  MSFlexGrid1.FixedRows = 1

End Sub

<----- Code End ----->
0
 

Author Comment

by:eliasis
Comment Utility
wsh2, thank you
just to understand it better what is "Microsoft Scripting Runtime" (SCRRUN.DLL) being used for?
0
 
LVL 14

Expert Comment

by:wsh2
Comment Utility
Setting the reference, provides the SCRRUN.DLL interfaces so that you can use the File System Object class programming contained inside of it. In essence, rather than programming all the nuts and bolts of File System Access, you are hooking into a Microsoft program library that provides that functionality, and then using the methods and properties there to achieve what you want.. <smile>.

The main difference between a Component and a Reference is that a Component usually requires a form / graphical interface while a reference does not. As such.. FSO (SCRRUN.DLL) is just like a Microsoft Control, only it does not require a Graphical User interface.
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
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…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

744 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

15 Experts available now in Live!

Get 1:1 Help Now