09-08-2003, 02:48 PM
please take a look
Private Sub Command1_Click()
getdir = BrowseForFolder(Me, "Select A Directory", "c:\") 'browses for folder
If Len(getdir) = 0 Then Exit Sub
sPattern = (getdir & "\*.mp3") 'looking in folder for .mp3
SendMessage List1.hWnd, LB_DIR, DDL_READWRITE, sPattern 'puts the list of .mp3 in listbox1
List2.AddItem (getdir & "\") 'puts the path in listbox2
List1.ListIndex = 0
List2.ListIndex = 0
i have added the path to list2 but what i need to do is add it the same amount of times as .mp3 in list1.
09-08-2003, 03:21 PM
Why not just use a FileListBox and DirListBox in combination?
09-08-2003, 03:44 PM
presentation looks better and just to know if it can be done.
09-08-2003, 03:54 PM
Use the ListCount property of List1 to create a loop to add the Path to List2. But..... the FileListBox and DirListBox are List Boxes, but with Files and Directories. How does the presentation look any worse than the normal List Box you're using?
09-08-2003, 04:01 PM
i understand where you are coming from vbjoe, what i meant was the browsing for files bit.
thanks for your input.
09-08-2003, 04:05 PM
Or even better use a single ListView control.
09-08-2003, 04:26 PM
For i = 1 To List1.ListCount
List2.AddItem (getdir & "\")
maybe there is other ways, i dont know, only been doing vb for 2 months inbetween work.
if there is please do tell.
i am making a mp3 player and only want to show the filetitle but get problems when there is different paths to different songs, so i thought i would have the paths in one listbox and the titles in another and make the path listbox invisible, i joined them together in the listbox click event (list1.listindex = list2.listindex)
09-08-2003, 04:35 PM
Ah, it you don't want the user to see the filepath, just the filetitle then you can store it the path's in a string array. Store the array index of the path that matches the filetitle in the ItemData property element that corresponds to the list item. eg:
' Add the list item
' Resize the array to hold the extra member
ReDim sArrFilePath(lstFiles.ListCount - 1)
' Save the file path in the array
sArrFilePath(UBound(sArrFilePath)) = sFilePath
' Link the two together by storing the array index in the ItemData property
lstFiles.ItemData(lstFile.NewIndex) = UBound(sArrFilePath)