String Comparision

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Kb

    String Comparision

    Hello There,

    How do i compare string such that A < B<... <Y<Z<BA<BB... <CA... <ZZ

    Thanks
    KB
  • Ciaran O''Donnell

    #2
    RE: String Comparision

    Write a comparer for it as Z < BA == false in normal coding. You would need
    to compare lengths first, then compare two of the same length as normal I
    imagine.

    HTH

    Ciaran O'Donnell

    "Kb" wrote:
    Hello There,
    >
    How do i compare string such that A < B<... <Y<Z<BA<BB... <CA... <ZZ
    >
    Thanks
    KB
    >

    Comment

    • PS

      #3
      Re: String Comparision


      "Kb" <forlist2001@ya hoo.comwrote in message
      news:ueHo7El3GH A.1588@TK2MSFTN GP02.phx.gbl...
      Hello There,
      >
      How do i compare string such that A < B<... <Y<Z<BA<BB... <CA... <ZZ
      It might be best to think of these as numbers but in base 36. Then the above
      comparisons would be correct.

      PS

      Comment

      • Jay B. Harlow [MVP - Outlook]

        #4
        Re: String Comparision

        In addition to the other comments, you might be able to PadLeft the shorter
        string with max length of the two strings...

        Something like:

        Public Class SpecialComparer
        Implements IComparer(Of String)

        Public Function Compare(ByVal x As String, ByVal y As String) As
        Integer Implements IComparer(Of String).Compare
        Dim totalWidth As Integer = Math.Max(x.Leng th, y.Length)
        Return String.Compare( x.PadLeft(total Width),
        y.PadLeft(total Width))
        End Function

        End Class




        --
        Hope this helps
        Jay B. Harlow [MVP - Outlook]
        ..NET Application Architect, Enthusiast, & Evangelist
        T.S. Bradley - http://www.tsbradley.net


        "Kb" <forlist2001@ya hoo.comwrote in message
        news:ueHo7El3GH A.1588@TK2MSFTN GP02.phx.gbl...
        Hello There,
        >
        How do i compare string such that A < B<... <Y<Z<BA<BB... <CA... <ZZ
        >
        Thanks
        KB

        Comment

        Working...