Results 1 to 14 of 14

Thread: [RESOLVED] [2005] Array of structures

Threaded View

  1. #1

    Thread Starter
    Admodistrator |2eM!x's Avatar
    Join Date
    Jan 2005
    Posts
    3,900

    Resolved [RESOLVED] [2005] Array of structures

    VB Code:
    1. Private Structure tPlaylist
    2.         Dim Text As String
    3.         Dim Name As String
    4.     End Structure
    5.     Dim Playlists() As tPlaylist

    Later on in my code, when I get the amount of playlists I do the following:
    VB Code:
    1. Public Sub readPlaylist(ByVal lv As ListView, ByVal cm As ContextMenuStrip)
    2.         Dim Names() As String = IO.Directory.GetFiles(Sansa & "PLAYLISTS\", "*PLA")
    3.         Dim Playlists(Names.Length - 1) As tPlaylist
    4.         For i As Int32 = 0 To Playlists.Length - 1
    5.             Playlists(i).Text = (My.Computer.FileSystem.ReadAllText(Names(i)).Replace(Convert.ToChar(0), String.Empty))
    6.             Playlists(i).Name = IO.Path.GetFileNameWithoutExtension(Names(i))
    7.         Next
    8.  
    9.     End Sub
    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?

    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??
    Last edited by |2eM!x; Dec 16th, 2006 at 04:28 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width