M
Michael D. Ober
In the code below, the IComparator function is never called. What am I
missing?
Public Class ArchiveInfo
Implements System.IComparable(Of ArchiveInfo)
Public FullName As String = ""
Public AccountNumber As String = ""
Public Sub New(ByRef Account As String, ByVal fname As String)
AccountNumber = Trim$(Account)
FullName = Trim$(fname)
End Sub
Public Function CompareTo(ByVal other As ArchiveInfo) As Integer
Implements System.IComparable(Of ArchiveInfo).CompareTo
Dim aiPath As String
Dim mePath As String
Dim i As Integer
i = InStr(other.FullName, "\archives\")
If i = 0 Then aiPath = other.FullName Else aiPath =
Mid$(other.FullName, i + Len("\archives\") + 1)
i = InStr(FullName, "\archives\")
If i = 0 Then mePath = FullName Else mePath = Mid$(FullName, i +
Len("\archives\") + 1)
Return aiPath.CompareTo(mePath)
End Function
End Class
Calling code:
dim Results as new Collection(of ArchiveInfo)
....
dim ai as new ArchiveInfo(someaccount, filename)
if not results.contains(ai) then results.add(ai)
===============
I understand that if results.count = 0 then the call shouldn't be made.
However, a breakpoint on the ArchiveInfo.CompareTo function is never
triggered.
missing?
Public Class ArchiveInfo
Implements System.IComparable(Of ArchiveInfo)
Public FullName As String = ""
Public AccountNumber As String = ""
Public Sub New(ByRef Account As String, ByVal fname As String)
AccountNumber = Trim$(Account)
FullName = Trim$(fname)
End Sub
Public Function CompareTo(ByVal other As ArchiveInfo) As Integer
Implements System.IComparable(Of ArchiveInfo).CompareTo
Dim aiPath As String
Dim mePath As String
Dim i As Integer
i = InStr(other.FullName, "\archives\")
If i = 0 Then aiPath = other.FullName Else aiPath =
Mid$(other.FullName, i + Len("\archives\") + 1)
i = InStr(FullName, "\archives\")
If i = 0 Then mePath = FullName Else mePath = Mid$(FullName, i +
Len("\archives\") + 1)
Return aiPath.CompareTo(mePath)
End Function
End Class
Calling code:
dim Results as new Collection(of ArchiveInfo)
....
dim ai as new ArchiveInfo(someaccount, filename)
if not results.contains(ai) then results.add(ai)
===============
I understand that if results.count = 0 then the call shouldn't be made.
However, a breakpoint on the ArchiveInfo.CompareTo function is never
triggered.