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.
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.
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
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>
Re: Vb6 List folder and icons into a listbox
You need another control, and did you notice my remark about code tags?
1 Attachment(s)
Re: Vb6 List folder and icons into a listbox
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! :)
Re: Vb6 List folder and icons into a listbox
@fafalone i go try it thankyou.
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
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