Private Sub Add_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PLAdd.Click
OpenFileDialog2.ShowDialog()
Playlist.Items.Add(OpenFileDialog2.FileName)
End Sub
Private Sub Remove_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PLRemove.Click
Playlist.Items.Remove(Playlist.SelectedItem)
End Sub
Private Sub PLSave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PLSave.Click
IO.Directory.CreateDirectory("C:\Selector\Playlists")
Dim w As New IO.StreamWriter("C:\Selector\Playlists\test.txt")
Dim i As Integer
For i = 0 To Playlist.Items.Count - 1
w.WriteLine(Playlist.Items.Item(i))
Next
w.Close()
End Sub
Private Sub PLLoad_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PLLoad.Click
Dim r As New IO.StreamReader("C:\Selector\Playlists\test.txt")
While (r.Peek() > -1)
Playlist.Items.Add(r.ReadLine)
End While
r.Close()
End Sub
Private Sub PLPlay_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PLPlay.Click
Process.Start(Playlist.SelectedItem)
End Sub
I want to allow the user to name their own file for the playlist instead of it being "test.txt".
I want a way to avoid duplicate song files.
I want a way to shorten the file name to exclude the file path. (I'll probably have that figured out on my own)
I want to overwrite one playlist with a loaded one.
Finally, How can I make this symbol, ►, in vb.net? (for my play button)
Last edited by 957; March 22nd, 2011 at 06:50 AM.
Reason: grammar
You could put an IF STATEMENT inside here, to pop up a message box for each song. Better idea would be to let user save a DIFFERENT name, and keep the filename separate for future use.
Do I have to import anything to use overwriteprompt?
My code has changed so that there is no longer a file saved to the computer.
Code:
Private Sub Add_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PLAdd.Click
OpenFileDialog2.ShowDialog()
Playlist.Items.Add(OpenFileDialog2.FileName)
End Sub
Private Sub Remove_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PLRemove.Click
Playlist.Items.Remove(Playlist.SelectedItem)
End Sub
Private Sub PLSave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PLSave.Click
Playlists.Items.Add(Playlist.Items)
End Sub
Private Sub PLLoad_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PLLoad.Click
Playlist.Items.Add(Playlists.Items)
End Sub
Private Sub PLPlay_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PLPlay.Click
If OpenFileDialog2.FileName = "" Then
Exit Sub
Else
Process.Start(Playlist.SelectedItem)
End If
End Sub
When I use this code to save a playlist to the second listbox as a single item that can be loaded as the original multiple items to the first listbox, all I get in the second listbox is the word, "(Collection)". Also, from this approach how could I allow the user to name their own playlist?
How is the user going to "save" their playlist if you don't write it to a file? If there not saving it to a file why would they have to name it? If you use SaveFileDialog it will allow the user to name the file. You will probably want to dictate the extension (like ".PL")
the main problem is transferring multiple items from one listbox to the other as only one item under a user-designated title like, "Avenged Sevenfold Songs"
If isPlay = True Then
If isPaused = False Then
btnPlay.Image = Image.FromFile("iconPause.png")
isPaused = True
isPlay = False
End If
GoTo Endline
End If
If isPlay = False Then
If isPaused = True Then
btnPlay.Image = Image.FromFile("iconPlay.png")
isPaused = False
isPlay = True
End If
End If
Private Sub PLMusicSN_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PLMusicSN.SelectedIndexChanged
PLMusicFP.SelectedIndex = PLMusicSN.SelectedIndex
End Sub
Private Sub PLMAdd_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PLMAdd.Click
OpenFileDialog2.ShowDialog()
PLMusicFP.Items.Add(OpenFileDialog2.FileName)
PLMusicSN.Items.Add(OpenFileDialog2.SafeFileName)
End Sub
Private Sub PLMRemove_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PLMRemove.Click
PLMusicFP.Items.Remove(PLMusicFP.SelectedItem)
PLMusicSN.Items.Remove(PLMusicSN.SelectedItem)
End Sub
Private Sub PLMSave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PLMSave.Click
IO.Directory.CreateDirectory("C:\Selector\Playlists")
Dim wFP As New IO.StreamWriter("C:\Selector\Playlists\MusicFP.pl")
Dim i As Integer
For i = 0 To PLMusicFP.Items.Count - 1
wFP.WriteLine(PLMusicFP.Items.Item(i))
Next
Dim wSN As New IO.StreamWriter("C:\Selector\Playlists\MusicSN.pl")
For i = 0 To PLMusicSN.Items.Count - 1
wSN.WriteLine(PLMusicSN.Items.Item(i))
Next
wFP.Close()
wSN.Close()
My.Settings.PLMDir = Me.PLMDirL.Text
My.Settings.Save()
End Sub
Private Sub PLMPlay_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PLMPlay.Click
PLMusicSN.SelectedItem = PLMusicFP.SelectedItem
If OpenFileDialog2.FileName = "" Then
Exit Sub
Else
Process.Start(PLMusicFP.SelectedItem)
End If
End Sub
Private Sub PLVideoSN_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PLMusicSN.SelectedIndexChanged
PLVideoFP.SelectedIndex = PLVideoSN.SelectedIndex
End Sub
Private Sub PLVAdd_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PLVAdd.Click
OpenFileDialog2.ShowDialog()
PLVideoFP.Items.Add(OpenFileDialog2.FileName)
PLVideoSN.Items.Add(OpenFileDialog2.SafeFileName)
End Sub
Private Sub PLVRemove_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PLVRemove.Click
PLVideoFP.Items.Remove(PLVideoFP.SelectedItem)
PLVideoSN.Items.Remove(PLVideoSN.SelectedItem)
End Sub
Private Sub PLVSave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PLVSave.Click
IO.Directory.CreateDirectory("C:\Selector\Playlists")
Dim wFP As New IO.StreamWriter("C:\Selector\Playlists\VideoFP.pl")
Dim i As Integer
For i = 0 To PLVideoFP.Items.Count - 1
wFP.WriteLine(PLVideoFP.Items.Item(i))
Next
Dim wSN As New IO.StreamWriter("C:\Selector\Playlists\VideoSN.pl")
For i = 0 To PLVideoSN.Items.Count - 1
wSN.WriteLine(PLVideoSN.Items.Item(i))
Next
wFP.Close()
wSN.Close()
My.Settings.PLVDir = Me.PLVDirL.Text
My.Settings.Save()
End Sub
Private Sub PLVPlay_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PLVPlay.Click
PLVideoSN.SelectedItem = PLVideoFP.SelectedItem
If OpenFileDialog2.FileName = "" Then
Exit Sub
Else
Process.Start(PLVideoFP.SelectedItem)
End If
End Sub
and in forms load
Code:
Me.PLMDirL.Text = My.Settings.PLMDir
Me.PLVDirL.Text = My.Settings.PLVDir
If PLMDirL.Text = "0" Then
IO.Directory.CreateDirectory("C:\Selector\Playlists\")
System.IO.File.Create("c:\Selector\Playlists\MusicFP.pl")
System.IO.File.Create("c:\Selector\Playlists\MusicSN.pl")
PLMDirL.Text = 1
Else
Dim rMFP As New IO.StreamReader("C:\Selector\Playlists\MusicFP.pl")
While (rMFP.Peek() > -1)
PLMusicFP.Items.Add(rMFP.ReadLine)
End While
rMFP.Close()
Dim rMSN As New IO.StreamReader("C:\Selector\Playlists\MusicSN.pl")
While (rMSN.Peek() > -1)
PLMusicSN.Items.Add(rMSN.ReadLine)
End While
rMSN.Close()
Dim rVFP As New IO.StreamReader("C:\Selector\Playlists\VideoFP.pl")
While (rVFP.Peek() > -1)
PLVideoFP.Items.Add(rVFP.ReadLine)
End While
rVFP.Close()
Dim rVSN As New IO.StreamReader("C:\Selector\Playlists\VideoSN.pl")
While (rVSN.Peek() > -1)
PLVideoSN.Items.Add(rVSN.ReadLine)
End While
rVSN.Close()
End If
If PLVDirL.Text = "0" Then
IO.Directory.CreateDirectory("C:\Selector\Playlists\")
System.IO.File.Create("c:\Selector\Playlists\VideoFP.pl")
System.IO.File.Create("c:\Selector\Playlists\VideoSN.pl")
PLVDirL.Text = 1
Else
Dim rVFP As New IO.StreamReader("C:\Selector\Playlists\VideoFP.pl")
While (rVFP.Peek() > -1)
PLVideoFP.Items.Add(rVFP.ReadLine)
End While
rVFP.Close()
Dim rVSN As New IO.StreamReader("C:\Selector\Playlists\VideoSN.pl")
While (rVSN.Peek() > -1)
PLVideoSN.Items.Add(rVSN.ReadLine)
End While
rVSN.Close()
End If
Bookmarks