Class for remembering the length of data and split them up


New member
Dec 9, 2021
Programming Experience
Hello everyone,

For an assignment, I load an xml file that lists the people per line.
The intent is to align these lines and split them up by the maximum length of the various data (maximum length of the name, maximum length of the country, etc.).
This data is stored in another class

I have no idea how to get the length, save it and retrieve it in the form.

Can anyone help me with this?

Form 1

Form 1:
Form 1
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click

Public Persons As XElement
Dim myNameLength As New LayoutClass

If Persons Is Nothing Then

   TextBox1.Text = "no person was found"
            Dim queryData = From Person In Persons.Descendants("Person")
                Where (Person.Attribute("Name")).Value <> ""
              Select Naam = Person.Attribute("Name").Value,
              Country= Person.Attribute("Country").Value
              Order By (Name)

TextBox1.Text = " "
TextBox1.Text = "The persons are: " & vbCrLf & myNameLength.PersonNameLength

End sub

Layout Class:
Layout Class

Public Class LayoutClass

    Public Property NameLength As Short = 16
    Public Property CountryLength As Short = 16
    Public Function PersonNameLength(PersonLength As Short) As Short
        Return Math.Max(PersonLength, NameLength)
    End Function

End Class

Thanks for the effort!
Last edited by a moderator: