Results 1 to 10 of 10

Thread: Vb6 List folder and icons into a listbox

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Apr 2021
    Posts
    166

    Vb6 List folder and icons into a listbox

    hello friends I managed to list the files of the current directory and even "browse" through a textbox thanks to the tip from the friend above but I couldn't find a way to list folders and if possible also some way to put an image in front of the program name even if it was just one, see how it looks and the code :

    https://imgur.com/a/fML1zZp

    Source:

    Dim NameFile As String, SubDir As String, udir As String
    Private Sub Form_Load()
    'SubDir = CurDir$ & "*.*" ' Change CurDir to whatever directory is being searched
    SubDir = udir & "*.*" ' Change CurDir to whatever directory is being searched
    NameFile = Dir$(SubDir)
    Do While NameFile <> vbNewstring
    List1.AddItem "[icon]" & NameFile
    NameFile = Dir$
    Loop
    End Sub


    Private Sub Text1_Change()
    udir = Text1.Text
    List1.Clear
    SubDir = udir & "*.*" ' Change CurDir to whatever directory is being searched
    NameFile = Dir$(SubDir)
    Do While NameFile <> vbNewstring
    List1.AddItem "[icon]" & NameFile
    NameFile = Dir$
    Loop
    End Sub

    -------------------------------


    But I still need to see folders and if there is a way to put an icon or create several pictureboxes by code and put the front, I will be grateful.

  2. #2
    Frenzied Member
    Join Date
    Feb 2003
    Posts
    1,807

    Re: Vb6 List folder and icons into a listbox

    Use the vbDirectory attribute with the Dir$ function:

    Code:
    NameFile = Dir$("*.*", vbDirectory)
    Also, please use code tags when posting code. These can be inserted using the "#" button in the toolbar above the message you're about to post on this forum. As to the icons: http://www.vb-helper.com/howto_show_file_icons.html.
    Last edited by Peter Swinkels; Apr 29th, 2021 at 02:28 AM.

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Apr 2021
    Posts
    166

    Re: Vb6 List folder and icons into a listbox

    @Peter Swinkels Thankyou i do show the folders name too with vb.directory but can'nt put a icon to front file name maybe listbox control dont use icons.

    i try:

    udir = Text1.Text
    List1.Clear
    SubDir = udir & "*.*" ' Change CurDir to whatever directory is being searched
    NameFile = Dir$(SubDir, vbDirectory)
    Do While NameFile <> vbNewstring
    List1.AddItem GetIcon & NameFile 'get icon get http://www.vb-helper.com/howto_show_file_icons.html
    NameFile = Dir$
    Loop

  4. #4
    PowerPoster wqweto's Avatar
    Join Date
    May 2011
    Location
    Sofia, Bulgaria
    Posts
    5,156

    Re: Vb6 List folder and icons into a listbox

    Btw, Windows 1.0 listbox does not have icons because it's hard to do it with a listbox control.

    You might need a listview control (notice the difference box vs view) to use icons in the list.

    cheers,
    </wqw>

  5. #5
    Frenzied Member
    Join Date
    Feb 2003
    Posts
    1,807

    Re: Vb6 List folder and icons into a listbox

    You need another control, and did you notice my remark about code tags?

  6. #6
    PowerPoster
    Join Date
    Jul 2010
    Location
    NYC
    Posts
    5,710

    Re: Vb6 List folder and icons into a listbox


  7. #7

    Thread Starter
    Addicted Member
    Join Date
    Apr 2021
    Posts
    166

    Re: Vb6 List folder and icons into a listbox

    @Peter Swinkels yes i see you post about tag and thank-you to this tip is very important!

  8. #8

    Thread Starter
    Addicted Member
    Join Date
    Apr 2021
    Posts
    166

    Re: Vb6 List folder and icons into a listbox

    @fafalone i go try it thankyou.

  9. #9

    Thread Starter
    Addicted Member
    Join Date
    Apr 2021
    Posts
    166

    Re: Vb6 List folder and icons into a listbox

    @wqweto i gree the project is imitate windows 1.0 i only think about add icons to customize it but the project is very nostalgic be. After close to this i try Ushell32 list.

    https://imgur.com/a/AFUiNd7

  10. #10
    Frenzied Member
    Join Date
    Aug 2020
    Posts
    1,447

    Re: Vb6 List folder and icons into a listbox

    Maybe the following thread is useful for you: (Threaded-Dir-Scan)

    https://www.vbforums.com/showthread....=1#post5002005

Tags for this Thread

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