BlakeMcKenna
Active member
- Joined
- Oct 27, 2008
- Messages
- 38
- Programming Experience
- 10+
I'm using VB.Net 2005. I have created a Structure Array that contains 7 fields. I am trying to figure out how to sort this thing and have no idea. I've been reading up on the Array.Sort function and I'm bombarded with Overloads. I just don't know how to set up the statement. Below is my code:
The RED Highlighted line is where I'm stuck at. I keep getting an error saying
"At least one object must implement IComparable."
Please help,
Thanks
VB.NET:
[COLOR="Blue"]'Structure Definition defined in a Module[/COLOR]
Private Structure CSVFile
Dim siteID As Integer
Dim tankID As Integer
Dim dispenser As Integer
Dim prodID As String
Dim invDate As String
Dim quantity As String
Dim date2 As String
End Structure
Private arrOutFile() As CSVFile
[COLOR="blue"]'This code is in a Sub-Procedure[/COLOR]
[COLOR="blue"]'I load the structure array with values[/COLOR]
ReDim Preserve arrOutFile(idx)
arrOutFile(idx).siteID = intSiteID
arrOutFile(idx).tankID = intTankID
arrOutFile(idx).dispenser = row(2)
arrOutFile(idx).prodID = strProdID
arrOutFile(idx).invDate = strDate1
arrOutFile(idx).quantity = strQuantity
arrOutFile(idx).date2 = strDate2
idx += 1
[COLOR="blue"]'When the array has finished loading, I try to sort it based on the 1st
'three fields in the structure (which I don't know how to setup as a key)[/COLOR]
If arrOutFile Is Nothing Then
Else
[COLOR="Red"]Array.Sort(arrOutFile)[/COLOR]
End If
The RED Highlighted line is where I'm stuck at. I keep getting an error saying
"At least one object must implement IComparable."
Please help,
Thanks