|
-
Apr 28th, 2021, 11:56 PM
#1
Thread Starter
Addicted Member
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.
-
Apr 29th, 2021, 02:24 AM
#2
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.
-
Apr 29th, 2021, 02:49 AM
#3
Thread Starter
Addicted Member
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
-
Apr 29th, 2021, 02:57 AM
#4
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>
-
Apr 29th, 2021, 05:53 AM
#5
Re: Vb6 List folder and icons into a listbox
You need another control, and did you notice my remark about code tags?
-
Apr 29th, 2021, 05:14 PM
#6
Re: Vb6 List folder and icons into a listbox
-
Apr 29th, 2021, 05:59 PM
#7
Thread Starter
Addicted Member
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!
-
Apr 29th, 2021, 05:59 PM
#8
Thread Starter
Addicted Member
Re: Vb6 List folder and icons into a listbox
@fafalone i go try it thankyou.
-
Apr 29th, 2021, 06:04 PM
#9
Thread Starter
Addicted Member
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
-
Apr 29th, 2021, 10:04 PM
#10
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|