Results 1 to 3 of 3

Thread: Directory/File Lister

Threaded View

  1. #1

    Thread Starter
    PowerPoster Nightwalker83's Avatar
    Join Date
    Dec 2001
    Location
    Adelaide, Australia
    Posts
    13,344

    Directory/File Lister

    This is a basic directory and file lister I created about 10 years back. I though I would paste the code here incase others could improve on it.

    vb Code:
    1. 'You need:
    2. '1 Drive List Box called Drive1
    3. '1 Directory List Box called Dir1
    4. '1 File lisrt box called File1
    5. '1 Combo box called cmbType
    6. '2 Command Buttons
    7. Dim n As Integer
    8.  
    9. Private Sub CmbType_Click()
    10. On Error GoTo err:
    11. File1.Pattern = CmbType.Text
    12. Exit Sub
    13. err:
    14. MsgBox ("Please select a file type!")
    15. End Sub
    16.  
    17. Private Sub Command1_Click()
    18. 'Close the program
    19. Unload Me
    20. End Sub
    21. 'Directory and File Lister
    22. 'Version 1.0
    23. 'Author: Nightwalker83
    24. 'Website: http://aaronspehr.net/
    25. Private Sub Command2_Click()
    26. 'Save list to a text file.
    27. For n = 1 To File1.ListCount
    28. Open App.Path & "\Files.txt" For Append As #1
    29. Print #1, File1.List(n)
    30. Close #1
    31. Next n
    32. End Sub
    33.  
    34. Private Sub Dir1_Change()
    35. File1.Path = Dir1.Path
    36. End Sub
    37.  
    38. Private Sub Drive1_Change()
    39. On Error GoTo err:
    40. Dir1.Path = Drive1.Drive
    41. Exit Sub
    42. err:
    43. MsgBox ("Please choose another drive!")
    44. End Sub
    45.  
    46. Private Sub Form_Load()
    47. frmDFL.Caption = "Directory and File Lister"
    48. Command1.Caption = "Exit"
    49. Command2.Caption = "Save"
    50. CmbType.Text = "File Type:"
    51. 'Library Files.
    52. CmbType.AddItem "*.dll"
    53. 'Word Documents.
    54. CmbType.AddItem "*.doc"
    55. 'Executables.
    56. CmbType.AddItem "*.exe"
    57. 'Text Files.
    58. CmbType.AddItem "*.txt"
    59. 'All Files.
    60. CmbType.AddItem "*.*"
    61. End Sub

    Nightwalker
    Last edited by Nightwalker83; Mar 21st, 2012 at 10:43 PM. Reason: Fixing comments!
    when you quote a post could you please do it via the "Reply With Quote" button or if it multiple post click the "''+" button then "Reply With Quote" button.
    If this thread is finished with please mark it "Resolved" by selecting "Mark thread resolved" from the "Thread tools" drop-down menu.
    https://get.cryptobrowser.site/30/4111672

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