You can definitely use the
Microsoft.VisualBasic.Collection class as
faulty.lee showed you - but a more elegant approach would be to create a separate class (inherited from
CollectionBase) to hold your items and then use this class inside your
Responses class.
For example - say I create a class called
ResponsesCollection:
CODE
Imports System.Collections
Public Class ResponsesCollection
Inherits CollectionBase
End Class
CollectionBase provides you with an inbuilt searchable & sortable collection called
List which can be accessed by both keys and index number. Any class inheriting CollectionBase gains these properties... The members methods which can operate on the List are
Add, AddRange, Remove, RemoveAt, Clear, IndexOf, Item, Contains etc. Once you inherit a class from CollectionBase, you don't need to declare the List separately... you can directly access it as
List.
A simple implementation of the members would be...
CODE
Imports System.Collections
Public Class ResponsesCollection
Inherits CollectionBase
Public Sub Add ( value As Object )
List.Add ( value )
End Sub
' AddRange
Public Sub AddRange( value[] As Object )
' Add items
ForEach vItem As Object in value
Add( vItem )
End Sub
' Remove
Public Sub Remove( value As Object )
' Remove item
List.Remove( value )
End Sub
' RemoveAt
Public Sub RemoveAt( index As Integer )
' If index is out of bounds - throw exception
If index > Count - 1 Or index < 0
Throw New ArgumentOutOfRangeException( "Index out of bounds." )
' If all is fine, remove item at specified index
List.RemoveAt( index )
End Sub
' Clear
Public Sub Clear()
' Clear List
List.Clear()
End Sub
' IndexOf
Public Function IndexOf( value As Object ) As Integer
Return List.IndexOf( value );
End Function
' Item
Public Function Item( index As Integer ) As Object
' If index is out of bounds - throw exception
If index > Count - 1 Or index < 0
Throw New ArgumentOutOfRangeException( "Index out of bounds." )
Return CType( List(index), Object)
End Function
' Insert
Public Sub Insert( index As Integer, value As Object )
List.Insert( index, value )
End Sub
' Contains
Public Function Contains( value As Object ) As Boolean
Return List.Contains( value );
End Function
End Class
Once you're done with the collection class as shown above, go over to your Responses class and implement this class by a familiar object name (say
Item) inside it... make sure you instantiate it in the constructor.
CODE
Public Class Responses
Public Item As ResponsesCollection
........
...........
' Constructor
Public Sub New
' Other constructor code
......
' Instantiate Collection
Item = New ResponsesCollection
....
End Sub
End Class
From now on whenever you instantiate Responses class anywhere in code, you'll be able to access/modify the list by
Responses.Item (x) or
Responses.Item.Add (x) or
Responses.Item.RemoveAt (x) etc....
Let me know if this helped

Cheers,
m^e
Comment/Reply (w/o sign-up)