Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1041931
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T15:25:41+00:00 2026-05-16T15:25:41+00:00

I’m trying to do something here with VB that I guess I’m not understanding

  • 0

I’m trying to do something here with VB that I guess I’m not understanding how to do it exactly. Sorry I’m not that good at OOP.

I have a number of things I’m creating and they have two values – parent name and child name (yes, actual people!).

So it would be like this:

Public Class Child
    Public Property ParentName As String
    Public Property ChildName As String
End Class

And then:

Public Class Parent
    Public Property ParentName As String
    Public Property ChildName() As String
End Class

Then I need to add these to a Parents class where a Parent can have one or more children.

I start by adding a Child. If that child’s Parent name already exists, just add the Child’s name to that parent, but if it doesn’t exist, create a new parent (with that child). Then add all parents to a collection of parents (with their 1 or more children).

A resulting list would look something like this:

Parents:

  1. Parent: Jonathan Murry
    1. Child: Carl Murry
  2. Parent: Kathleen Anderson
    1. Child: Steven Anderson
    2. Child: Deborah Anderson
    3. Child: Thomas Anderson
  3. Parent: Xu Jing
    1. Child: Liu Ming
    2. Child: Liu Ning

(note on the last one – the parent/child last names don’t need to match – in this case, the children take the father’s last name instead of the mother’s, but we don’t list the father).

How would I create these type of classes so that I can add children to a parent, add a parent to parents and then ensure it is querable with something like Linq?

Thx in advance.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T15:25:42+00:00Added an answer on May 16, 2026 at 3:25 pm

    Since all of them are persons, perhaps there should instead be a Person class. Each person may a Mother, a Father and a collection of Children. That way you can create graphs over several generations and with all sorts of constellations.

    Public Class Person
        Public Property Name As String
        Public Property Mother As Person
        Public Property Father As Person
        Public Property Children As List(Of Person)
    End Class
    

    Update
    Here is a fuller (and somewhat reworked) example that perhaps can help to shed some light:

    The Person class, slightly changes (replaced Mother / Father with Parent, made the Children property `ReadOnly´)

    Public Class Person
        Public Property Name As String
        Public Property Parent As Person
        Private _children As New List(Of Person)
    
        Public ReadOnly Property Children As List(Of Person)
            Get
                Return _children
            End Get
        End Property
    
    End Class
    

    And a sample program creating a Person list, and posing a LINQ query.

    Module Program
        Sub Main()
            Dim persons As IEnumerable(Of Person) = GetPersonGraph()
            Dim jonathansChildren As IEnumerable(Of Person)
            jonathansChildren = persons.Where(Function(p) _
                                    Not p.Parent Is Nothing _
                                    AndAlso p.Parent.Name = "Jonathan Murphy")
    
            For Each child As Person In jonathansChildren
                Console.WriteLine(child)
            Next
        End Sub
    
    
        Function GetPersonGraph() As IEnumerable(Of Person)
            Dim result As New List(Of Person)
            Dim parent As Person
            Dim child As Person
    
            parent = New Person()
            parent.Name = "Jonathan Murphy"
            result.Add(parent)
    
            child = New Person()
            child.Name = "Carl Murry"
            child.Parent = parent
            parent.Children.Add(child)
            result.Add(child)
    
            Return result
        End Function
    End Module
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
Basically, what I'm trying to create is a page of div tags, each has
I am trying to understand how to use SyndicationItem to display feed which is
link Im having trouble converting the html entites into html characters, (&# 8217;) i
this is what i have right now Drawing an RSS feed into the php,
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have just tried to save a simple *.rtf file with some websites and
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
Seemingly simple, but I cannot find anything relevant on the web. What is the
Does anyone know how can I replace this 2 symbol below from the string

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.