• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 198
  • Last Modified:

Creating custom classes

Hi folks,

I've created two custom classes:

 1) Master.vb
 2) ObjectDetail.vb

I want to achieve the desired functionality:

 In master.vb, there is a property called .Items. I would like it to be a collection of ObjectDetail.vb objects.

How can I do this?

Thank you,

OnError_Fix
0
OnError_Fix
Asked:
OnError_Fix
  • 2
1 Solution
 
cyberdevil67Commented:
Hi OnError_Fix,

 under expert settings you'll see the setting you need

Cheers!
0
 
cyberdevil67Commented:
OnError_Fix,

 sorry wrong area. ignore my post
0
 
amyhxuCommented:
You can create a collection class:

Public Class ObjectDetail_Collection
    Inherits System.Collections.CollectionBase

    Public Sub Add(ByVal newObjectDetail As ObjectDetail)

        list.Add(newObjectDetail)

    End Sub

    Public Sub Remove(ByVal index As Integer)

        If index > Count - 1 Or index < 0 Then

        Else
            list.RemoveAt(index)
        End If

    End Sub

    Public ReadOnly Property Item(ByVal index As Integer) As ObjectDetail
        Get
            Return CType(list.Item(index), ObjectDetail)
        End Get
    End Property

End Class

Here's an example of creating your own collection class: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vbcon/html/vaconCreatingYourOwnCollectionClass.asp

Then in your Master class:

Public Class Master

...

    Private _ObjectDetailCollection As ObjectDetail_Collection

    Public Property Items() As ObjectDetail_Collection
        Get
            Return _ObjectDetailCollection
        End Get
        Set(By_Val Value As ObjectDetail_Collection)
            _ObjectDetailCollection = Value
        End Set
    End Property

...
   
End Class
0
 
OnError_FixAuthor Commented:
Brilliant -- just what I needed. Thank you!
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now