Results 1 to 3 of 3

Thread: Semi-Recursive Search with Dir

  1. #1

    Thread Starter
    Admodistrator |2eM!x's Avatar
    Join Date
    Jan 2005
    Posts
    3,900

    Semi-Recursive Search with Dir

    VB Code:
    1. Option Explicit
    2. Dim i As Long
    3. Dim MyCount As Long
    4.  
    5. Private Function GetFolder(iPath As String) As String
    6. Dim MyDir As String, x As Long
    7.     MyDir = Dir(iPath, vbDirectory): i = 0
    8.         Do Until MyDir = ""
    9.             If InStr(MyDir, ".") = 0 Then
    10.                  list1.AddItem MyDir
    11.             End If
    12.             MyDir = Dir
    13.         Loop
    14.         MyCount = list1.ListCount
    15.     Do Until i >= MyCount
    16.     DoEvents
    17.     MyCount = list1.ListCount
    18.         Do Until InStr(list1.List(i), "-") = 0
    19.             i = i + 1
    20.         Loop
    21.                     Call Get2Folder(iPath & list1.List(i) & "\")
    22.                 i = i + 1
    23.     Loop
    24. End Function
    25.  
    26. Private Function Get2Folder(iFolder As String) As String
    27. Dim iDir As String
    28.     iDir = Dir(iFolder, vbDirectory)
    29.         Do Until iDir = ""
    30.             If InStr(iDir, ".") = 0 And Len(iDir) > 1 Then
    31.                  list1.AddItem "-" & iDir, i + 1
    32.             End If
    33.             iDir = Dir
    34.         Loop
    35. End Function
    36.  
    37. Private Sub Form_Activate()
    38.     Call GetFolder("C:\Program Files\")
    39. End Sub

  2. #2
    Banned dglienna's Avatar
    Join Date
    Jun 2004
    Location
    Center of it all
    Posts
    17,901

    Re: Semi-Recursive Search with Dir

    Might want to do something if there are more than 32K folders. Nice job, though.

  3. #3

    Thread Starter
    Admodistrator |2eM!x's Avatar
    Join Date
    Jan 2005
    Posts
    3,900

    Re: Semi-Recursive Search with Dir

    I also had an idea where you wouldnt have to check for the -'s etc..it just involved alot more looping than i wanted to do

    thanks mate

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