Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. a realy simple question about collections

a realy simple question about collections

Scheduled Pinned Locked Moved Visual Basic
databasetutorialquestion
4 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • H Offline
    H Offline
    HaloZa
    wrote on last edited by
    #1

    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

    G 1 Reply Last reply
    0
    • H HaloZa

      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

      G Offline
      G Offline
      Guffa
      wrote on last edited by
      #2

      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; }

      H 1 Reply Last reply
      0
      • G Guffa

        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; }

        H Offline
        H Offline
        HaloZa
        wrote on last edited by
        #3

        i didnt think i needed to add that code as well Public dparmor As new dpGenerals will thats the line there ... then ie dparmor.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 :/

        G 1 Reply Last reply
        0
        • H HaloZa

          i didnt think i needed to add that code as well Public dparmor As new dpGenerals will thats the line there ... then ie dparmor.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 :/

          G Offline
          G Offline
          Guffa
          wrote on last edited by
          #4

          But you did show that code already, but that's not the collection you are adding the values to. I'm talking about the collection named List that you are using in the code. --- b { font-weight: normal; }

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups