isnoend2001
asked on
Loop thru a directory put filenames in a combobox vb6
I have a program where a homeowner can get-track bids on different home repair-improvements
The homowner can type a new project name into a combo box(cboBids) and new Directory is created
I want to put all the directory names in a combobox on form load
The homeowners directory is created when entered into textboxes
Typical Paths
C:\Documents and Settings\All Users.WINDOWS\Documents\Ro ofCalculat or\William s 1247 RiverBend rd\Painting Bids
C:\Documents and Settings\All Users.WINDOWS\Documents\Ro ofCalculat or\William s 1247 RiverBend rd\Roofing Bids
C:\Documents and Settings\All Users.WINDOWS\Documents\Ro ofCalculat or\William s 1247 RiverBend rd\Bathroom Remodle Bids
C:\Documents and Settings\All Users.WINDOWS\Documents\Ro ofCalculat or\William s 1247 RiverBend rd\New Fence Bids
The last part
Example:
With Me.cboBids
.AddItem "paintingBids"
.AddItem "Roofing Bids"
.AddItem "Bathroom Remodle Bids"
.AddItem "New Fence Bids"
End With
How can this be done ?
The homowner can type a new project name into a combo box(cboBids) and new Directory is created
I want to put all the directory names in a combobox on form load
The homeowners directory is created when entered into textboxes
Typical Paths
C:\Documents and Settings\All Users.WINDOWS\Documents\Ro
C:\Documents and Settings\All Users.WINDOWS\Documents\Ro
C:\Documents and Settings\All Users.WINDOWS\Documents\Ro
C:\Documents and Settings\All Users.WINDOWS\Documents\Ro
The last part
Example:
With Me.cboBids
.AddItem "paintingBids"
.AddItem "Roofing Bids"
.AddItem "Bathroom Remodle Bids"
.AddItem "New Fence Bids"
End With
How can this be done ?
ASKER
Thanks ste5an
Is there a way without using fso ?
mstrOwnerFolder holds this:
C:\Documents and Settings\All Users.WINDOWS\Documents\Ro ofCalculat or\William s 1247 RiverBend rd
tried this to no avail:
Is there a way without using fso ?
mstrOwnerFolder holds this:
C:\Documents and Settings\All Users.WINDOWS\Documents\Ro
tried this to no avail:
Sub AddFoldersToCbo()
Dim MyFile, MyPath, MyName
MyPath = mstrOwnerFolder ' Set the path.
MyName = Dir(MyPath, vbDirectory) ' Retrieve the first entry.
Do While MyName <> ""
If MyPath = vbDirectory Then
Debug.Print MyName
End If
MyName = Dir
Loop
End Sub
Try this:
Note the additions: the GetAttr() function and the last backslash in root path.
Note the additions: the GetAttr() function and the last backslash in root path.
Dim MyFile, MyPath, MyName
MyPath = "c:\temp\" 'Set the path (must append the last backslash "\")
MyName = Dir(MyPath, vbDirectory) 'Retrieve the first entry.
Do While MyName <> ""
If (GetAttr(MyPath & MyName) And vbDirectory) Then
If (MyName <> ".") And (MyName <> "..") Then
Debug.Print MyName
End If
End If
MyName = Dir()
Loop
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks jkaios
My pleasure, so glad it works!
Open in new window