|
-
Nov 11th, 2008, 04:51 AM
#1
Thread Starter
Frenzied Member
How to populate file name in the directory?
I have files in the C:\database.. I would like to populate the files in this folder into my combo box? How to start this?
-
Nov 11th, 2008, 04:59 AM
#2
Thread Starter
Frenzied Member
Re: How to populate file name in the directory?
Where I have to put the directory name "C:\Database" in your code.
-
Nov 11th, 2008, 05:07 AM
#3
Re: How to populate file name in the directory?
I have simplified the above code for you 
vb Code:
'Add a reference to 'Microsoft Scripting Runtime'
Sub Searchforfiles()
Dim Fso As Object, fmain As Folder, aFile As File
Set Fso = CreateObject("Scripting.FileSystemObject")
'Pass your folder path here
Set fmain = Fso.GetFolder("C:\Database")
For Each aFile In fmain.Files
MsgBox aFile.Name
'Code to add to combobox
Next
Set fmain = Nothing
Set aFile = Nothing
Set Fso = Nothing
End Sub
A good exercise for the Heart is to bend down and help another up...
Please Mark your Thread " Resolved", if the query is solved
MyGear:
★ CPU ★ Ryzen 5 5800X
★ GPU ★ NVIDIA GeForce RTX 3080 TI Founder Edition
★ RAM ★ G. Skill Trident Z RGB 32GB 3600MHz
★ MB ★ ASUS TUF GAMING X570 (WI-FI) ATX Gaming
★ Storage ★ SSD SB-ROCKET-1TB + SEAGATE 2TB Barracuda IHD
★ Cooling ★ NOCTUA NH-D15 CHROMAX BLACK 140mm + 10 of Noctua NF-F12 PWM
★ PSU ★ ANTEC HCG-1000-EXTREME 1000 Watt 80 Plus Gold Fully Modular PSU
★ Case ★ LIAN LI PC-O11 DYNAMIC XL ROG (BLACK) (G99.O11DXL-X)
★ Monitor ★ LG Ultragear 27" 240Hz Gaming Monitor
★ Keyboard ★ TVS Electronics Gold Keyboard
★ Mouse ★ Logitech G502 Hero
-
Nov 11th, 2008, 05:21 AM
#4
Thread Starter
Frenzied Member
Re: How to populate file name in the directory?
Thank you so much.. I would like to search a specific files with the extension *.shp.. How to do that?
-
Nov 11th, 2008, 05:25 AM
#5
Re: How to populate file name in the directory?
vb Code:
'Add a reference to 'Microsoft Scripting Runtime'
Sub Searchforfiles()
Dim Fso As Object, fmain As Folder, aFile As File
Set Fso = CreateObject("Scripting.FileSystemObject")
'Pass your folder path here
Set fmain = Fso.GetFolder("C:\Database")
For Each aFile In fmain.Files
If Right(aFile.Name, 4) = ".shp" Then
'Code to add to combobox
End If
Next
Set fmain = Nothing
Set aFile = Nothing
Set Fso = Nothing
End Sub
A good exercise for the Heart is to bend down and help another up...
Please Mark your Thread " Resolved", if the query is solved
MyGear:
★ CPU ★ Ryzen 5 5800X
★ GPU ★ NVIDIA GeForce RTX 3080 TI Founder Edition
★ RAM ★ G. Skill Trident Z RGB 32GB 3600MHz
★ MB ★ ASUS TUF GAMING X570 (WI-FI) ATX Gaming
★ Storage ★ SSD SB-ROCKET-1TB + SEAGATE 2TB Barracuda IHD
★ Cooling ★ NOCTUA NH-D15 CHROMAX BLACK 140mm + 10 of Noctua NF-F12 PWM
★ PSU ★ ANTEC HCG-1000-EXTREME 1000 Watt 80 Plus Gold Fully Modular PSU
★ Case ★ LIAN LI PC-O11 DYNAMIC XL ROG (BLACK) (G99.O11DXL-X)
★ Monitor ★ LG Ultragear 27" 240Hz Gaming Monitor
★ Keyboard ★ TVS Electronics Gold Keyboard
★ Mouse ★ Logitech G502 Hero
-
Nov 11th, 2008, 07:52 AM
#6
Re: How to populate file name in the directory?
And without the FSO
Code:
Private Sub Command1_Click()
Dim strLoad As String
Combo1.Clear
strLoad = Dir("c:\Database\*.*")
Do While strLoad > vbNullString
Combo1.AddItem strLoad
strLoad = Dir
Loop
End Sub
-
Nov 11th, 2008, 07:54 AM
#7
Re: How to populate file name in the directory?
 Originally Posted by matrik02
Thank you so much.. I would like to search a specific files with the extension *.shp.. How to do that?
If all you want are those, then why load all files
Code:
Private Sub Command1_Click()
Dim strLoad As String
Combo1.Clear
strLoad = Dir("c:\Database\*.shp")
Do While strLoad > vbNullString
Combo1.AddItem strLoad
strLoad = Dir
Loop
End Sub
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
|