**Developer**,
Have you looked at the overloads to ChangeType? One of them accepts a format
provider, Is there a format provider you can pass that will ignore the
commas?
If I get a chance to later I will look. Post if you find something.
Hope this helps
Jay
| That's great. Just what I wanted!
|
| One aside, Some numbers as text are of format 123,456,789
|
| If I used Cint it is smart enough to handle them.
|
| But Convert.Change to Int32 is not.
| I can make this a special case but do you happen to know a type that
| supports numbers like that?
|
|
| Thanks a lot
|
|
| | > **Developer**
| > In addition to the other comments.
| >
| > I would use something like:
| >
| > Dim dataType As TypeCode
| > Dim xText, yText As String
| > Dim xObject, yObject As Object
| > Dim result As Integer
| >
| > xObject = Convert.ChangeType(xText, dataType)
| > yObject = Convert.ChangeType(yText, dataType)
| >
| > result = Comparer.Default.Compare(xObject, yObject)
| >
| > - or -
| >
| > result = Comparer.DefaultInvariant.Compare(xObject, yObject)
| >
| >
| > Convert.ChangeType will change the text variable to the requested type
| > code
| > (Int32 for example). Be certain to review ChangeType's overloads!
| >
| > Comparer.Default does the comparison based on Thread.CurrentCulture,
while
| > Comparer.DefaultInvariant does the comparison based on
| > CultureInfo.InvariantCulture.
| >
| > Hope this helps
| > Jay
| >
| >
| > | > |I do the following:
| > |
| > | Select Case mDataType(mColumnToSort)
| > |
| > | Case TypeCode.Int32
| > |
| > | Result = CInt(xText).CompareTo(CInt(yText))
| > |
| > | Case TypeCode.String
| > |
| > | Result=...
| > |
| > |
| > |
| > | I wonder if I could somehow write one statement that would compare all
| > types
| > | using mDataType(mColumnToSort) to automate the conversion?
| > |
| > |
| >
| >
|
|