The pertinant piece of code is:
' Determine whther the type being comapared is a date type
Try
' Parse the two objects into Datetime.
Dim firstdate As System.DateTime = DateTime.Parse(CType(x, ListViewItem).SubItems(col).Text)
Dim seconddate As System.DateTime = DateTime.Parse(CType(y, ListViewItem).SubItems(col).Text)
' Compare the two dates
returnval = DateTime.Compare(firstdate, seconddate)
' If neither compared objects has a valid date format, compare it as a string
Catch
' String Compare the two objects
returnval = [String].Compare(CType(x, ListViewItem).SubItems(col).Text, CType(y, ListViewItem).SubItems(col).Text)
End Try
Trouble is, the data is some of my columns is null and causes the error:
An unhandled exception of type 'System.ArgumentOutOfRangeException' occurred in system.windows.forms.dll
Additional information: Specified argument was out of the range of valid values.
Does anyone know how to make it work when there are nulls in the columns?
Im running it in debug mode, there is no stacktrace, only the error that I have list previously. The messagebox has Break, Continue, Ignore (grayed out) and Help buttons.
Of course the Help button does not provide anything useful.
You should put a breakpoint there and then use Quick Watches to see which of those doesn't ahve any items or at least doesn't have the index you are looking for.