a realy simple question about collections
-
ok this is starting to drive me insane :( . I know its realy simple but for the life of me i cannot figure out how to do it. This is my code.
Public Class dpGenerals Inherits System.Collections.CollectionBase Private m_oSections As Sections Public ReadOnly Property Section(ByVal Index As Integer) As Section Get Return DirectCast(List(Index), Section) End Get End Property Public Function Add(ByVal key As Integer, ByVal value As String, ByVal sec As String) As Boolean Try Dim oSection As New Section oSection.key = key oSection.value = value oSection.sec = sec List.Add(oSection) Return True Catch E As Exception Return False End Try End Function Public Function Add(ByVal oSection As Section) As Boolean Try List.Add(oSection) Return True Catch E As Exception Return False End Try End Function End Class Public Class Sections Inherits System.Collections.CollectionBase Private m_oSections As Sections Private m_key As Integer 'Default Public ReadOnly Property Sections(ByVal Index As Integer) As Section Get Return DirectCast(List(Index), Section) End Get End Property Public ReadOnly Property Keys(ByVal Index As Integer) As key Get Return DirectCast(List(Index), key) End Get End Property Public Function Addbla(ByVal key As Integer, ByVal value As String, ByVal sec As String) As Boolean Try Dim oSection As New Section oSection.key = key oSection.value = value oSection.sec = sec List.Add(oSection) Return True Catch E As Exception Return False End Try End Function End Class Public Class Section Private m_sec As String Private m_type As Integer Private m_key As Integer Private m_value As String Private m_keys As Keys Private m_sections As Sections Public Sub New() MyBase.New() m_keys = New keys() End Sub Public Property sec() As String Get Return m_sec End Get Set(ByVal value As String) m_sec = value End Set End Property Public Property type() As Integer Get
-
ok this is starting to drive me insane :( . I know its realy simple but for the life of me i cannot figure out how to do it. This is my code.
Public Class dpGenerals Inherits System.Collections.CollectionBase Private m_oSections As Sections Public ReadOnly Property Section(ByVal Index As Integer) As Section Get Return DirectCast(List(Index), Section) End Get End Property Public Function Add(ByVal key As Integer, ByVal value As String, ByVal sec As String) As Boolean Try Dim oSection As New Section oSection.key = key oSection.value = value oSection.sec = sec List.Add(oSection) Return True Catch E As Exception Return False End Try End Function Public Function Add(ByVal oSection As Section) As Boolean Try List.Add(oSection) Return True Catch E As Exception Return False End Try End Function End Class Public Class Sections Inherits System.Collections.CollectionBase Private m_oSections As Sections Private m_key As Integer 'Default Public ReadOnly Property Sections(ByVal Index As Integer) As Section Get Return DirectCast(List(Index), Section) End Get End Property Public ReadOnly Property Keys(ByVal Index As Integer) As key Get Return DirectCast(List(Index), key) End Get End Property Public Function Addbla(ByVal key As Integer, ByVal value As String, ByVal sec As String) As Boolean Try Dim oSection As New Section oSection.key = key oSection.value = value oSection.sec = sec List.Add(oSection) Return True Catch E As Exception Return False End Try End Function End Class Public Class Section Private m_sec As String Private m_type As Integer Private m_key As Integer Private m_value As String Private m_keys As Keys Private m_sections As Sections Public Sub New() MyBase.New() m_keys = New keys() End Sub Public Property sec() As String Get Return m_sec End Get Set(ByVal value As String) m_sec = value End Set End Property Public Property type() As Integer Get
-
You are adding everyting into the same list, and you don't even create that list anywhere, you just use it out of the blue... --- b { font-weight: normal; }
i didnt think i needed to add that code as well
Public dparmor As new dpGenerals
will thats the line there ... then iedparmor.section(0).keys(0).key dparmor.section(0).section(0).key dparmor.section(0).section(0).section(0).key
but i cant get the add to work as mentioned above, the adding of a section works cus it Class dpGenerals (add). But the property dpGenerals.Section is a collection of the type section, so i cant call the dparmor.section.addbla(). I just dont know how to convert the code to be able to call that fucntion addbla. I dunno if that makes it any clearer ? -- modified at 5:50 Saturday 11th March, 2006 i just figured it out ... made 2 changes and works now :/ -
i didnt think i needed to add that code as well
Public dparmor As new dpGenerals
will thats the line there ... then iedparmor.section(0).keys(0).key dparmor.section(0).section(0).key dparmor.section(0).section(0).section(0).key
but i cant get the add to work as mentioned above, the adding of a section works cus it Class dpGenerals (add). But the property dpGenerals.Section is a collection of the type section, so i cant call the dparmor.section.addbla(). I just dont know how to convert the code to be able to call that fucntion addbla. I dunno if that makes it any clearer ? -- modified at 5:50 Saturday 11th March, 2006 i just figured it out ... made 2 changes and works now :/