Question How to do this - Group Enums?

buda56

New member
Joined
Jun 15, 2012
Messages
2
Location
Adelaide
Programming Experience
5-10
Hi,
I am trying to work out a way to group a collection of items like an enum so that I can access them through code else where in my program.

i.e I have list of items and sub items

G1Level1
Level2
Level2
Level3
G2Level1
Level2​
Level3
Level3
G3Level1
Level2​
Level2
Level3
Level4
Level2​
etc..

I would then like to be able to access then like: G1Level1.Leve2.Leve3

Would anyone be able to advise if this is possible or achievable.

Thanks
Regards..
Peter
 
Hello there,

Here is the code. Try to understand the algorithm, and then change it or add Levels as you wish.


PublicStructureGLevels
Dim Level1 AsObject
End
Structure

PublicClassG1
Private L1 AsNewGLevels
Public Level2 AsG2

Public
Property Level1 AsObject
Get
Return L1.Level1
EndGet
Set(ByVal value AsObject)
L1.Level1 = value
EndSet
EndProperty
EndClass

PublicClassG2

Private L2 AsNewG1
PublicProperty Level1 AsObject
Get
Return L2.Level1
EndGet
Set(ByVal value AsObject)
L2.Level1 = value
EndSet
EndProperty
PublicProperty Level2 AsObject
Get
Return L2.Level1
EndGet
Set(ByVal value AsObject)
L2.Level1 = value
EndSet
EndProperty
EndClass


PublicClassForm1
PrivateSub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) HandlesMyBase.Load
Dim G1Level AsNewG1
G1Level.Level1 = 1
G1Level.Level2.Level1 = 2
G1Level.Level2.Level2 = 2
EndSub
End
Class
 
Back
Top