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

  • SEARCH
  • Home
  • 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 8002491
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T16:22:59+00:00 2026-06-04T16:22:59+00:00

I have this XML file from which I’m grabbing all the data: <?xml version=1.0

  • 0

I have this XML file from which I’m grabbing all the data:

<?xml version="1.0" encoding="utf-8"?>
<Tabel>
  <Member>
    <Naam>Cruciatum</Naam>
    <Kills>10</Kills>
    <Deaths>2</Deaths>
    <Score>2222</Score>
  </Member>
  <Member>
    <Naam>test</Naam>
    <Kills>123</Kills>
    <Deaths>12</Deaths>
    <Score>12222</Score>
  </Member>
  <Member>
    <Naam>test2</Naam>
    <Kills>159</Kills>
    <Deaths>12</Deaths>
    <Score>2222</Score>
  </Member>
  <Member>
    <Naam>test3</Naam>
    <Kills>159</Kills>
    <Deaths>122</Deaths>
    <Score>222284</Score>
  </Member>
  <Member>
    <Naam>test4</Naam>
    <Kills>15</Kills>
    <Deaths>1229</Deaths>
    <Score>129453</Score>
  </Member>
</Tabel>

I got it all to show in 5 different listboxes (1 for each childnode under “Member”).

I have this following code to do that.

Public Class Rank
    Dim memberNodes As XmlNodeList
    Dim memberNode As XmlNode
    Dim x As Short
    Dim dataNodes As XmlNodeList
    Dim firstinrow As Boolean
    Dim datalist(5) As String
    Dim y As Short

    Private Sub Rank_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
        lstView.Items.Clear()
        x = 0
        Dim doc As New XmlDocument()
        doc.Load("C:\Members.xml")
        memberNodes = doc.GetElementsByTagName("Member")
        For Each memberNode In memberNodes
            dataNodes = memberNode.ChildNodes
            y = 1
            For Each dataNode As XmlNode In dataNodes
                datalist(y) = dataNode.InnerText
                datalist(0) = (x + 1).ToString
                y += 1
            Next
            datalist(5) = datalist(4)
            datalist(4) = FormatNumber((datalist(2) / datalist(3)), 3)
            Dim lvi As New ListViewItem(datalist)
            lstView.Items.Add(lvi)
            x += 1
        Next

    End Sub
End Class

That code is working fine for now, displaying the full list.
But now I need all the data sorted by the values in the Score column of the listview, so for in the following example:
Result so far

I would need the first line to say: “1 test3 159 122 1.303 222284”

Second line the 2nd place on Score, etc.

Update:
Instead of seperate listboxes I’m now using 1 listview, as recommended by @SteveDog

  • 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-06-04T16:23:00+00:00Added an answer on June 4, 2026 at 4:23 pm

    Instead of separate list boxes, use a ListView control with the View property set to Details, or use a DataGridView control. If you must use separate list boxes like that, you will need to implement the IComparable interface on each class to override the sorting.

    Sorting in a ListView control is admittedly a bit of a pain. It’s nice to have it be so flexible, but it’s a pain when all you want to do is a simple sort. First, you need to create a sorter object that implements the IComparer interface. For instance:

    Public Class ScoreSorter
        Implements IComparer
    
        Public Function Compare(ByVal x As Object, ByVal y As Object) As Integer Implements IComparer.Compare
            Try
                Dim xItem As ListViewItem = CType(x, ListViewItem)
                Dim yItem As ListViewItem = CType(y, ListViewItem)
                Dim xInt As Integer = Integer.Parse(xItem.SubItems(5).Text)
                Dim yInt As Integer = Integer.Parse(yItem.SubItems(5).Text)
                Return yInt - xInt
            Catch
                Return 0
            End Try
        End Function
    End Class
    

    Then you need to set the ListView control’s ListViewItemSorter property to a new instance of the sorter object, then tell it to sort, such as:

    ListView1.ListViewItemSorter = New ScoreSorter()
    ListView1.Sort()
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this data from a xml file: <?xml version=1.0 encoding=utf-8 ?> <words> <id>...</id>
I have this xml file <?xml version=1.0 encoding=UTF-8?> <bo:C837ClaimParent xsi:type=bo:C837ClaimParent xmlns:xsi=http://www.w3.org/2001/XMLSchema-instance xmlns:bo=http://somelongpathHere/process/bo> <claimAux> ...
I have this XML at http://localhost/file.xml : <?xml version=1.0 encoding=utf-8?> <val:Root xmlns:val=http://www.hw-group.com/XMLSchema/ste/values.xsd> <Agent> <Version>2.0.3</Version>
I have this simple XML file : <?xml version=1.0 encoding=utf-8 ?> <Artists> <artist artistId=1>
So say I have this XML file: <?xml version=1.0 encoding=utf-8 standalone=yes?> <Root> <Category Name=Tasties>
I have this XML file, from which I'd like to count the number of
I have XML file which looks like this: <?xml version=1.0?> <results> <row id=100><name>name blah</name></row>
I am parsing an xml file from an API which I have converted into
I have text file from which I need to get data by line by
I have an xml file from which I am extracting html using LINQ to

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.