Results 1 to 2 of 2

Thread: ListBox EASY (ASAP)

  1. #1

    Thread Starter
    Addicted Member Stick's Avatar
    Join Date
    Aug 1999
    Location
    Iowa
    Posts
    152

    Post

    I need to Add All Files and FOLDERS into a List box from a defined dir.
    How would i do this ?

  2. #2
    Guru Aaron Young's Avatar
    Join Date
    Jun 1999
    Location
    Red Wing, MN, USA
    Posts
    2,177

    Post

    The easiest way would be to use a Directory and File Listbox, otherwise you can Recurse the Directories yourself with the Dir Function, ie.
    Code:
    Private Sub Command1_Click()
        List1.Clear
        Call RecurseDir(InputBox("Enter Start Directory..", "List Dir/File", "C:\"))
    End Sub
    
    Private Sub RecurseDir(ByVal sStartIn As String)
        Dim sDirs() As String
        Dim iDirs As Integer
        Dim sDir As String
        
        If Right(sStartIn, 1) <> "\" Then sStartIn = sStartIn & "\"
        sDir = Dir(sStartIn & "*", vbDirectory + vbHidden + vbNormal + vbReadOnly + vbSystem)
        While Len(sDir)
            If (GetAttr(sStartIn & sDir) And vbDirectory) = vbDirectory Then
                If Left(sDir, 1) <> "." Then
                    ReDim Preserve sDirs(iDirs)
                    sDirs(iDirs) = sDir
                    iDirs = iDirs + 1
                End If
            ElseIf Left(sDir, 1) <> "." Then
                List1.AddItem sStartIn & sDir
            End If
            sDir = Dir
        Wend
        For iDirs = 0 To iDirs - 1
            Call RecurseDir(sStartIn & sDirs(iDirs))
        Next
    End Sub
    ------------------
    Aaron Young
    Analyst Programmer
    [email protected]
    [email protected]


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