|
-
Sep 20th, 2001, 12:36 AM
#1
Thread Starter
Lively Member
how do I display the items in a folder in a text box?
I know I need a folder, c:\windows\desktop
I know I need a listbox, listThis
I know I need to open the folder so I can get the files within and I am pretty sure I need to use a loop to display the folder items in the list box, listThis
all of this under one control button I have tried something like this:
Private Sub getFilesInFolder_Click()
searchPath = "c:\windows\desktop"
for i = 0 to listThis
listThis.additem = searchPath
next i
and I get an error. I know I am missing something, and probably got somethings messed up.
What am I missing?
-
Sep 20th, 2001, 01:25 AM
#2
What you have done doesn't make sense. So just to ******** is a little.
Your for loop, you go from i = 0 to the name of your listbox, which is properly what causes your error.
Secondly if your for-loop had worked, you are only adding the string containing "C:\Windows\Desktop" to the listbox.
THis code should give you what you wan't:
Code:
Dim strFileFound As String
strFileFound = Dir("C:\Windows\Desktop\", vbDirectory) 'Includes files and folders
Do While strFileFound <> ""
If strFileFound <> "." And strFileFound <> ".." Then
Me.List1.AddItem strFileFound
End If
strFileFound = Dir
Loop
-
Sep 20th, 2001, 01:48 AM
#3
Thread Starter
Lively Member
THANK YOU SOOO MUCH! I have been going nuts trying to figure this one out. Just what I needed
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
|