?
Solved

Grid and File list

Posted on 2000-04-07
3
Medium Priority
?
225 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 14

Accepted Solution

by:
wsh2 earned 400 total points
ID: 2693311
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
ID: 2693431
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
ID: 2693568
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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
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…
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…
Suggested Courses
Course of the Month9 days, 17 hours left to enroll

762 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