Reputation: 137
Im working on a console application which sends and receives data through a WinSock control. for each incremental stream that gets added to the buffer i have generated an array list and appended incoming integral address (IPv4) from the stream. however, while listing the data in another control, it appears in Unsorted manner.
Private Sub clrHandler_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles clrHandler.Click
dim clrReckon as Integer
clrReckon = PostCLRCount
PostCLRCount += 1
Upvotes: 0
Views: 670
Reputation: 34846
Assuming you have 5 integer values for each of the button click counts, then you can order them in ascending order like this:
Public Class ButtonCount
Private m_Name As String
Public Property Name() As String
Get
Return m_Name
End Get
Set
m_Name = Value
End Set
End Property
Private m_Count As Integer
Public Property Count() As Integer
Get
Return m_Count
End Get
Set
m_Count = Value
End Set
End Property
Public Sub New(name As String, count As Integer)
Name = name
Count = count
End Sub
End Class
Dim listButtonCount As New List(Of ButtonCount)()
listButtonCount.Add(New ButtonCount("A", aCount))
listButtonCount.Add(New ButtonCount("B", bCount))
listButtonCount.Add(New ButtonCount("C", cCount))
listButtonCount.Add(New ButtonCount("D", dCount))
listButtonCount.Add(New ButtonCount("E", eCount))
Note: aCount
, bCount
, cCount
, dCount
and eCount
are the five Integer
values you are keeping track of for clicks of the respective buttons.
Dim sortedListButtonCount As List(Of ButtonCount) = listButtonCount.OrderBy(Function(c) c.Count).ToList()
Upvotes: 0
Reputation: 19367
You could store the values in an Array, or other Collection, and use Array.Sort.
If you store them in separate variables then you would need to write the code that sorts them.
Upvotes: 2