crestsolutions
asked on
Collection Classes in VB.NET
I want a collection class to be a property of another class in VB.NET. How do I implement this? What I am asking is analagous to a recordsets and fields in VB6. I want to be able to create an instance of one class via another class. e.g.
dim x as new recordset
dim y as new field
set y = x.fields.add("Field1", ...................)
dim x as new recordset
dim y as new field
set y = x.fields.add("Field1", ...................)
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Public Class Class1
'Normal properties
Public MyProperty As String
'a Collection variable
Public MyCollection As Collection = New Collection
Public Sub MyMethod()
'Normal methods
End Sub
End Class
Then you can use the class as
Dim objClass1 as Class1=New Class1
objClass1.MyCollection.Add
'This is the simplest example, you might add some Abstraction in your actual code
'And not have All Public variables/collections etc.