I am trying to set up a nested collection so I can run statements like
this
Implement the following classes:
Step
StepCollection inherits CollectionBase
Question
QuestionCollection inherits CollectionBase
Add an instance of QuestionCollection to the Step class, and you'll
have the desired effect - not "nested classes", by the way, it's
called "strong-typing". Good modelling.
Rgds,
This is what I have so far, could you edit the code below so I could see an
example of what you are talking about?
Most importantly how to add the data to the QuestionsColl so that it is
inbedded in the StepsColl...
Thank you so much, feel free to critique my code, I am always looking for
ways to improve.
Atley
Public Class Steps
'Info Out
Public SOutTitle as string
Public SOutName as string
Public SOutDesc as string
'''''''''''''''''''''''''''''''''''''''''''''
'''Do You Mean This'''
'''''''''''''''''''''''''''''''''''''''''''''
Public SQuestions As QuestionsCol
'''''''''''''''''''''''''''''''''''''''''''''
''\Do You Mean This/''
'''''''''''''''''''''''''''''''''''''''''''''
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
MySteps.Add(CurrStep)
CurrStep = Nothing
Next X
End Function