Class for remembering the length of data and split them up

Angeltje1992

New member
Joined
Dec 9, 2021
Messages
1
Programming Experience
Beginner
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
Code:
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"
        Else
            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

Code:
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:
Back
Top