Click here to Skip to main content
15,893,722 members
Home / Discussions / Visual Basic
   

Visual Basic

 
GeneralRe: error on the path how come it become null?? Pin
Guffa11-Mar-06 6:33
Guffa11-Mar-06 6:33 
GeneralRe: error on the path how come it become null?? Pin
campbells11-Mar-06 16:19
campbells11-Mar-06 16:19 
Questionado.net Pin
SVb.net11-Mar-06 3:20
SVb.net11-Mar-06 3:20 
AnswerRe: ado.net Pin
Michael P Butler11-Mar-06 4:55
Michael P Butler11-Mar-06 4:55 
QuestionUsing MS-Access 2000 Database in vb.net Pin
ssfargade11-Mar-06 1:47
ssfargade11-Mar-06 1:47 
AnswerRe: Using MS-Access 2000 Database in vb.net Pin
Joshua Quick11-Mar-06 8:09
Joshua Quick11-Mar-06 8:09 
GeneralRe: Using MS-Access 2000 Database in vb.net Pin
ssfargade13-Mar-06 7:03
ssfargade13-Mar-06 7:03 
Questiona realy simple question about collections Pin
HaloZa10-Mar-06 21:33
HaloZa10-Mar-06 21:33 
ok this is starting to drive me insane Frown | :( . I know its realy simple but for the life of me i cannot figure out how to do it.
This is my code.

<br />
Public Class dpGenerals<br />
    Inherits System.Collections.CollectionBase<br />
<br />
    Private m_oSections As Sections<br />
<br />
    Public ReadOnly Property Section(ByVal Index As Integer) As Section<br />
        Get<br />
            Return DirectCast(List(Index), Section)<br />
        End Get<br />
    End Property<br />
<br />
    Public Function Add(ByVal key As Integer, ByVal value As String, ByVal sec As String) As Boolean<br />
        Try<br />
            Dim oSection As New Section<br />
            oSection.key = key<br />
            oSection.value = value<br />
            oSection.sec = sec<br />
            List.Add(oSection)<br />
            Return True<br />
        Catch E As Exception<br />
            Return False<br />
        End Try<br />
    End Function<br />
<br />
    Public Function Add(ByVal oSection As Section) As Boolean<br />
        Try<br />
            List.Add(oSection)<br />
            Return True<br />
        Catch E As Exception<br />
            Return False<br />
        End Try<br />
    End Function<br />
<br />
End Class<br />
<br />
<br />
<br />
Public Class Sections<br />
    Inherits System.Collections.CollectionBase<br />
    Private m_oSections As Sections<br />
    Private m_key As Integer<br />
<br />
    'Default<br />
    Public ReadOnly Property Sections(ByVal Index As Integer) As Section<br />
        Get<br />
            Return DirectCast(List(Index), Section)<br />
        End Get<br />
    End Property<br />
<br />
    Public ReadOnly Property Keys(ByVal Index As Integer) As key<br />
        Get<br />
            Return DirectCast(List(Index), key)<br />
        End Get<br />
    End Property<br />
<br />
    Public Function Addbla(ByVal key As Integer, ByVal value As String, ByVal sec As String) As Boolean<br />
        Try<br />
            Dim oSection As New Section<br />
            oSection.key = key<br />
            oSection.value = value<br />
            oSection.sec = sec<br />
            List.Add(oSection)<br />
            Return True<br />
        Catch E As Exception<br />
            Return False<br />
        End Try<br />
    End Function<br />
<br />
End Class<br />
<br />
<br />
Public Class Section<br />
    Private m_sec As String<br />
    Private m_type As Integer<br />
    Private m_key As Integer<br />
    Private m_value As String<br />
<br />
    Private m_keys As Keys<br />
    Private m_sections As Sections<br />
<br />
    Public Sub New()<br />
        MyBase.New()<br />
        m_keys = New keys()<br />
    End Sub<br />
<br />
    Public Property sec() As String<br />
        Get<br />
            Return m_sec<br />
        End Get<br />
        Set(ByVal value As String)<br />
            m_sec = value<br />
        End Set<br />
    End Property<br />
    Public Property type() As Integer<br />
        Get<br />
            Return m_type<br />
        End Get<br />
        Set(ByVal value As Integer)<br />
            m_type = value<br />
        End Set<br />
    End Property<br />
    Public Property key() As Integer<br />
        Get<br />
            Return m_key<br />
        End Get<br />
        Set(ByVal value As Integer)<br />
            m_key = value<br />
        End Set<br />
    End Property<br />
    Public Property value() As String<br />
        Get<br />
            Return m_value<br />
        End Get<br />
        Set(ByVal Value As String)<br />
            m_value = Value<br />
        End Set<br />
    End Property<br />
<br />
    Public ReadOnly Property Keys() As keys<br />
        Get<br />
            Return m_keys<br />
        End Get<br />
    End Property<br />
    Public ReadOnly Property Sections() As Sections<br />
        Get<br />
            Return m_sections<br />
        End Get<br />
    End Property<br />
<br />
End Class<br />
<br />
<br />
<br />
<br />
Module Modtest<br />
    Public dparmor As New dpGenerals<br />
    Public Sub Test()<br />
        dparmor.Add(4, "light", "armor")<br />
        dparmor.Add(2, "heavy", "armor")<br />
<br />
        dparmor.Section.Addbla(1, "SUB!1", "armobSuB")<br />
        'dparmor.Add.Addbla(1, "SUB!1", "armobSuB")<br />
<br />
        MsgBox(dparmor.Section(0).key)<br />
    End Sub<br />
End Module<br />


All i am trying to do is have a few nested collections :/.
Aparmor.add() allows me to add a section
but for the life of me i cant get the addbla() to add a sub section.
I would like many levels deep dparmor.section(0).section(0).section(0).key
i would also like many levels of keys
ie dparmor.section(0).keys(0).key
dparmor.section(0).section(0).key

Please i know its probably so simple but i just cant figure it out, i do know that sections is the collection of a type section and that the addbla is under sections and not section. but i dont know how to go about fixing this. As you can see there are a few more properites but i think if i can just get that part working the rest will fall into place.
Please any help with this is greatly appreciated.
Thanks
AnswerRe: a realy simple question about collections Pin
Guffa10-Mar-06 22:04
Guffa10-Mar-06 22:04 
GeneralRe: a realy simple question about collections Pin
HaloZa10-Mar-06 23:34
HaloZa10-Mar-06 23:34 
GeneralRe: a realy simple question about collections Pin
Guffa11-Mar-06 0:31
Guffa11-Mar-06 0:31 
Questionproblems in tool bar display Pin
contact ajo10-Mar-06 20:52
contact ajo10-Mar-06 20:52 
AnswerRe: problems in tool bar display Pin
Joshua Quick11-Mar-06 8:04
Joshua Quick11-Mar-06 8:04 
Questionexecute permission in studio.net Pin
_tasleem10-Mar-06 18:49
_tasleem10-Mar-06 18:49 
AnswerRe: execute permission in studio.net Pin
Dave Kreskowiak11-Mar-06 14:14
mveDave Kreskowiak11-Mar-06 14:14 
QuestionQuarry a MySql DB from a windows Form? Pin
Darshon10-Mar-06 18:26
Darshon10-Mar-06 18:26 
AnswerRe: Quarry a MySql DB from a windows Form? Pin
Guffa11-Mar-06 2:37
Guffa11-Mar-06 2:37 
GeneralRe: Quarry a MySql DB from a windows Form? Pin
Darshon11-Mar-06 5:31
Darshon11-Mar-06 5:31 
QuestionWriting a Funtion in C#|VB.NET and using it in Crystal Report Pin
superdragon10-Mar-06 16:22
superdragon10-Mar-06 16:22 
Questionhow to loop midi file?? Pin
campbells10-Mar-06 16:00
campbells10-Mar-06 16:00 
AnswerRe: how to loop midi file?? Pin
Superwill11-Mar-06 1:41
Superwill11-Mar-06 1:41 
GeneralRe: how to loop midi file?? Pin
campbells11-Mar-06 4:24
campbells11-Mar-06 4:24 
QuestionDynamic model using XML Pin
peepys10-Mar-06 15:10
peepys10-Mar-06 15:10 
AnswerRe: Dynamic model using XML Pin
peepys11-Mar-06 17:37
peepys11-Mar-06 17:37 
QuestionMultiple sounds Pin
Superwill10-Mar-06 13:41
Superwill10-Mar-06 13:41 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.