du kan vel "udskrive" indholdet af din listbox, som jeg går ud fra indeholder filplaceringen af de enkelte mp3'er, til en fil og således give mulighed for at navngive filen med din playlist-navn etc.
hej du må undskylde jeg ikke svarer før end nu. Jeg får ingen mails fra eksperten mere... :s
Har lavet et testprojekt til dig her:
'----------------------------------------- 'Kræver: ' Reference til MS Scripting Runtime ' Control: Microsoft Common Controls ' 1 listview = listview1 ' 1 commandbutton = command1 '-----------------------------------------
Option Explicit
Private Sub Command1_Click() If Me.ListView1.ListItems.Count > 0 Then Call gemPlayList("c:\playlist.txt") Else MsgBox "Ingen sange på playlist!", vbExclamation, "Playlisten er tom" End If End Sub Private Sub gemPlayList(dinPlacering As String)
Dim itemX As ListItem
'angiv din placering Open dinPlacering For Output As #1 For Each itemX In Me.ListView1.ListItems Write #1, itemX.Tag & "||" & itemX.Text 'adskiller med || Next Close #1
End Sub Private Sub Form_Load()
Call startListView Call HentFiler
End Sub Private Sub startListView()
With Me.ListView1 .ColumnHeaders.Clear .ListItems.Clear .View = lvwReport .ColumnHeaders.Add , , "MP3", .Width .FullRowSelect = True .HideColumnHeaders = False .HideSelection = False End With
End Sub Private Sub HentFiler() Dim fso As New FileSystemObject Dim strSti As String
Dim dinFolder As Folder Dim dinFile As File Dim dinFileType As String
strSti = "N:\Musik" dinFileType = "mp3" If fso.FolderExists(strSti) = True Then Set dinFolder = fso.GetFolder(strSti) End If
For Each dinFile In dinFolder.Files If LCase(Right(dinFile.Name, 3)) = dinFileType Then Call skrivFiler2Listbox(Trim(LCase(dinFile.Name)), LCase(dinFile.Path)) End If Next
Set dinFolder = Nothing Set fso = Nothing
End Sub
Private Sub skrivFiler2Listbox(strFileName As String, strFilePath As String)
With Me.ListView1 .ListItems.Add(, , strFileName).Tag = strFilePath End With
nå jeg legede lige lidt videre... håber du kan bruge det... :o)
'----------------------------------------- 'Kræver: ' Reference til MS Scripting Runtime ' Control: Microsoft Common Controls ' 1 listview = listview1 ' 2 commandbutton = command1(hent) og command2(gem) ' husk at rette filplaceringer til der hvor du vil hhv gemme og hente din musik og playlist fra '-----------------------------------------
Option Explicit Private Sub formFunctions(udfører As Boolean)
If udfører = False Then Me.Enabled = True MousePointer = vbDefault Else Me.Enabled = False MousePointer = vbHourglass End If
End Sub Private Sub Command1_Click() Call formFunctions(True)
If Me.ListView1.ListItems.Count > 0 Then Call gemPlayList("c:\playlist.txt") MsgBox "Playlisten er gemt...", vbInformation, "Gemt" Else MsgBox "Ingen sange på playlist!", vbExclamation, "Playlisten er tom" End If
Call formFunctions(False) End Sub Private Sub gemPlayList(dinPlacering As String)
Dim itemX As ListItem
'angiv din placering Open dinPlacering For Output As #1 For Each itemX In Me.ListView1.ListItems Write #1, itemX.Tag Next Close #1
End Sub
Private Sub Command2_Click() Call formFunctions(True)
Call startListView Call HentPlayList("C:\playlist.txt") MsgBox "Playlisten er blevet hentet...", vbInformation, "Hentet"
Call formFunctions(False) End Sub
Private Sub HentPlayList(dinPlacering As String) Dim dinPlayList As String Dim arrFiler Dim i As Integer Dim fileNavn As String
Open dinPlacering For Input As #1 dinPlayList = Input(LOF(1), 1) Close #1
arrFiler = Split(dinPlayList, vbCrLf)
For i = LBound(arrFiler) To UBound(arrFiler) fileNavn = FileExists(Replace(CStr(arrFiler(i)), Chr(34), "")) If fileNavn <> "" Then Call skrivFiler2Listbox(LCase(fileNavn), Replace(CStr(arrFiler(i)), Chr(34), "")) End If Next
End Sub
Private Function FileExists(strFileName As String) As String Dim fso As New FileSystemObject Dim fileX As File
If fso.FileExists(strFileName) = True Then Set fileX = fso.GetFile(strFileName) FileExists = fileX.Name Else FileExists = "" End If
Set fileX = Nothing Set fso = Nothing End Function
Private Sub Form_Load()
Call startListView Call HentFiler
End Sub Private Sub startListView()
With Me.ListView1 .ColumnHeaders.Clear .ListItems.Clear .View = lvwReport .ColumnHeaders.Add , , "MP3", .Width .FullRowSelect = True .HideColumnHeaders = False .HideSelection = False End With
End Sub Private Sub HentFiler() Dim fso As New FileSystemObject Dim strSti As String
Dim dinFolder As Folder Dim dinFile As File Dim dinFileType As String
strSti = "N:\Musik" dinFileType = "mp3" If fso.FolderExists(strSti) = True Then Set dinFolder = fso.GetFolder(strSti) End If
For Each dinFile In dinFolder.Files If LCase(Right(dinFile.Name, 3)) = dinFileType Then Call skrivFiler2Listbox(Trim(LCase(dinFile.Name)), LCase(dinFile.Path)) End If Next
Set dinFolder = Nothing Set fso = Nothing
End Sub
Private Sub skrivFiler2Listbox(strFileName As String, strFilePath As String)
With Me.ListView1 .ListItems.Add(, , strFileName).Tag = strFilePath End With
Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.