A
Atley
I am trying to set up a nested collection so I can run statements like this:
me.lblquestions.text = mysteps.item(1).questions(1).Asked
Any ideas on how to do this? I have created a Class(Steps) with a nested
Class(Questions) inside of it and a Collection of that Class(Steps) and it
works fine, but the Nested Collection(Questions) is escaping me.
Help!
My Code:
Public Class Steps
'Info Out
Public SOutTitle as string
Public SOutName as string
Public SOutDesc as string
Public SQuestions As QuestionsCol
End Class
Public Class Questions
Public Title As String
Public Type As Integer
Public Answer ' Variant
Public WControl As Integer
End Class
Public Class StepsColl
Inherits System.Collections.CollectionBase
Public Sub Add (ByVal aStep as Steps)
list.add(aStep)
End Sub
Public Sub Remove (ByVal index as Integer)
If Index > Count or Count < 1 Then
Msgbox ("Index is not valid")
Else
list.remove(aStep)
End If
End Sub
Public ReadOnly Property Item (ByVal index as Integer) As Steps
Get
If Index > Count or Count < 1 Then
Msgbox ("Index is not valid")
Else
Return CType (list.Item(Index), Steps)
End If
End Get
End Sub
End Class
Public Class QuestionsColl
Inherits System.Collections.CollectionBase
Public Sub Add (ByVal aQuestion as Questions)
list.add(aQuestion)
End Sub
Public Sub Remove (ByVal index as Integer)
If Index > Count or Count < 1 Then
Msgbox ("Index is not valid")
Else
list.remove(aStep)
End If
End Sub
Public ReadOnly Property Item (ByVal index as Integer) As Questions
Get
If Index > Count or Count < 1 Then
Msgbox ("Index is not valid")
Else
Return CType (list.Item(Index), Questions)
End If
End Get
End Sub
End Class
Public MySteps as New StepsColl
Public Function PopulateSteps
Dim X As Integer
Dim Y As Integer
StepCount = 5
For X = 0 to StepCount -1
Dim CurrStep As New Steps
CurrStep.SOutName = "Drawings Start Date" & X + 1
''''
' I Cannot Figure out how to make the nested questions 1-5 for this step and
make it stick. HELP!
''''
MySteps.Add(CurrStep)
CurrStep = Nothing
Next X
End Function
me.lblquestions.text = mysteps.item(1).questions(1).Asked
Any ideas on how to do this? I have created a Class(Steps) with a nested
Class(Questions) inside of it and a Collection of that Class(Steps) and it
works fine, but the Nested Collection(Questions) is escaping me.
Help!
My Code:
Public Class Steps
'Info Out
Public SOutTitle as string
Public SOutName as string
Public SOutDesc as string
Public SQuestions As QuestionsCol
End Class
Public Class Questions
Public Title As String
Public Type As Integer
Public Answer ' Variant
Public WControl As Integer
End Class
Public Class StepsColl
Inherits System.Collections.CollectionBase
Public Sub Add (ByVal aStep as Steps)
list.add(aStep)
End Sub
Public Sub Remove (ByVal index as Integer)
If Index > Count or Count < 1 Then
Msgbox ("Index is not valid")
Else
list.remove(aStep)
End If
End Sub
Public ReadOnly Property Item (ByVal index as Integer) As Steps
Get
If Index > Count or Count < 1 Then
Msgbox ("Index is not valid")
Else
Return CType (list.Item(Index), Steps)
End If
End Get
End Sub
End Class
Public Class QuestionsColl
Inherits System.Collections.CollectionBase
Public Sub Add (ByVal aQuestion as Questions)
list.add(aQuestion)
End Sub
Public Sub Remove (ByVal index as Integer)
If Index > Count or Count < 1 Then
Msgbox ("Index is not valid")
Else
list.remove(aStep)
End If
End Sub
Public ReadOnly Property Item (ByVal index as Integer) As Questions
Get
If Index > Count or Count < 1 Then
Msgbox ("Index is not valid")
Else
Return CType (list.Item(Index), Questions)
End If
End Get
End Sub
End Class
Public MySteps as New StepsColl
Public Function PopulateSteps
Dim X As Integer
Dim Y As Integer
StepCount = 5
For X = 0 to StepCount -1
Dim CurrStep As New Steps
CurrStep.SOutName = "Drawings Start Date" & X + 1
''''
' I Cannot Figure out how to make the nested questions 1-5 for this step and
make it stick. HELP!
''''
MySteps.Add(CurrStep)
CurrStep = Nothing
Next X
End Function