|
-
May 19th, 2002, 03:43 PM
#1
Thread Starter
Hyperactive Member
Displaying listbox items in text1.text
How can I make it so a user selects a directory, and then all images in that directory that are .gif, .jpeg, .jpg, and .bmp are then added to a list box.
In the listbox I want the full directory paths of the files, not just the name of them.
Thanks for any help anyone can give
Last edited by Animelion; May 19th, 2002 at 05:33 PM.
~ Animelion
-
May 19th, 2002, 03:55 PM
#2
-= B u g S l a y e r =-
sample for u
VB Code:
Private Sub Command3_Click()
Dim sFile As String
Dim s As String
Dim sPath As String
Dim sArr() As String
Dim i As Integer
sPath = "C:\TEST\"
sFile = Dir(sPath & "*.bmp")
Do While sFile <> ""
s = s & sPath & sFile & vbCrLf
sFile = Dir
Loop
sFile = Dir(sPath & "*.jpg")
Do While sFile <> ""
s = s & sPath & sFile & vbCrLf
sFile = Dir
Loop
sFile = Dir(sPath & "*.gif")
Do While sFile <> ""
s = s & sPath & sFile & vbCrLf
sFile = Dir
Loop
'get all the files found into an array
sArr = Split(s, vbCrLf)
'fill the listbox
List1.Clear
For i = 0 To UBound(sArr())
List1.AddItem sArr(i)
Next i
End Sub
-
May 19th, 2002, 04:04 PM
#3
-= B u g S l a y e r =-
a bit more "sexy" 
VB Code:
Private Sub Command3_Click()
Dim sFile As String
Dim s As String
Dim sPath As String
Dim sArr() As String
Dim sFileMasks(4) As String
Dim i As Integer
sFileMasks(0) = "*.BMP"
sFileMasks(1) = "*.JPG"
sFileMasks(2) = "*.TIF"
sFileMasks(3) = "*.JPEG"
sFileMasks(4) = "*.GIF"
sPath = "C:\TEST\"
For i = 0 To UBound(sFileMasks())
sFile = Dir(sPath & sFileMasks(i))
Do While sFile <> ""
s = s & sPath & sFile & vbCrLf
sFile = Dir
Loop
Next i
'get all the files found into an array
sArr = Split(s, vbCrLf)
'fill the listbox
List1.Clear
For i = 0 To UBound(sArr())
List1.AddItem sArr(i)
Next i
End Sub
-
May 19th, 2002, 04:06 PM
#4
-= B u g S l a y e r =-
from the other post, I take it u want to use the FSO instead ?
-
May 19th, 2002, 04:15 PM
#5
Thread Starter
Hyperactive Member
:)
New question, same basis.
If I have a File List Box what code do i need to have so that a user can click a button and all files selected will be added to a listbox ?
It is kinda like before, but I can't figure out howto adapt it.
Thanks for any help anyone gives
-
May 19th, 2002, 04:26 PM
#6
-= B u g S l a y e r =-
huh ... so u found the FileListBox then did u ??
-
May 19th, 2002, 04:26 PM
#7
-= B u g S l a y e r =-
VB Code:
Private Sub Command4_Click()
Dim i As Integer
For i = 0 To File1.ListCount - 1
If File1.Selected(i) Then List1.AddItem File1.FileName
Next i
End Sub
-
May 19th, 2002, 05:31 PM
#8
Thread Starter
Hyperactive Member
Another Q :)
Ok ok, 1 more for now 
If I have a list box filled with lets say 10 items
How can I scroll thru the listbox and have the 1st item diplayed in text1.text, then have the second item displayed in text1.text, and so on, all the way till all the items in the listbox have been displayed.
Thanks for any help anyone can provide.
-
May 19th, 2002, 06:07 PM
#9
-= B u g S l a y e r =-
VB Code:
Private Sub Command1_Click()
Dim i As Integer
Text1.Text = ""
For i = 0 To List1.ListCount - 1
Text1.Text = Text1.Text & List1.List(i) & vbCrLf
Next i
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
|