VB Code:
Private Structure tPlaylist Dim Text As String Dim Name As String End Structure Dim Playlists() As tPlaylist
Later on in my code, when I get the amount of playlists I do the following:
However playlists is returning a nullreference error. If I set the definition up top to a constant number, then it works- but I cannot do it like that. The Playlists() needs to be public so I can access it througout my class. Any ideas?VB Code:
Public Sub readPlaylist(ByVal lv As ListView, ByVal cm As ContextMenuStrip) Dim Names() As String = IO.Directory.GetFiles(Sansa & "PLAYLISTS\", "*PLA") Dim Playlists(Names.Length - 1) As tPlaylist For i As Int32 = 0 To Playlists.Length - 1 Playlists(i).Text = (My.Computer.FileSystem.ReadAllText(Names(i)).Replace(Convert.ToChar(0), String.Empty)) Playlists(i).Name = IO.Path.GetFileNameWithoutExtension(Names(i)) Next End Sub
edit**
I changed my code. Now it works inside the readPlaylist() sub, but the values of Playlists() are lost after the sub closes..How can I fix this??





Reply With Quote