spen_lang
asked on
VB Net - Sort a Multi List that Contains Duplicates
Hi,
I need add 6 values (3 rows) to a list and then sort the list by the datetime value. However, this value is not unique. I am then outputting the list to a string.
The following works well until I have duplicate values. How can I change the following to allow duplicates?
This is code that I am adding to a Reporting Services report.
Thanks, Greg
I need add 6 values (3 rows) to a list and then sort the list by the datetime value. However, this value is not unique. I am then outputting the list to a string.
The following works well until I have duplicate values. How can I change the following to allow duplicates?
This is code that I am adding to a Reporting Services report.
Thanks, Greg
Friend Function GetStatusHistory(sStatus1 As String, dtStatusTime1 As Nullable(Of DateTime), sStatus2 As String, dtStatusTime2 As Nullable(Of DateTime), sStatus3 As String, dtStatusTime3 As Nullable(Of DateTime)) As String
Dim sResult As String = ""
Dim lstStatus As New System.Collections.Generic.SortedList(Of DateTime, String)
If Not IsNothing(dtStatusTime1) Then
lstStatus.Add(dtStatusTime1, sStatus1)
End If
If Not IsNothing(dtStatusTime2) Then
lstStatus.Add(dtStatusTime2, sStatus2)
End If
If Not IsNothing(dtStatusTime3) Then
lstStatus.Add(dtStatusTime3, sStatus3)
End If
For Each pair As System.Collections.Generic.KeyValuePair(Of DateTime, String) In lstStatus
If String.IsNullOrEmpty(sResult) Then
sResult = pair.Value + " @ " + pair.Key.ToString("dd/MM/yy HH:mm")
Else
sResult = sResult + ", " + pair.Value + " @ " + pair.Key.ToString("dd/MM/yy HH:mm")
End If
Next
Return sResult
End Function
ASKER CERTIFIED SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
Add Imports System.Linq
-saige-
-saige-
ASKER
Hi, I tried this but unfortunately it did not work. I have now created a Class with the function you provided in it and added as a reference to the report.
ASKER
Any idea how I can fix this?