CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 7 of 7
  1. #1
    Join Date
    Sep 2001
    Location
    Indiana
    Posts
    6

    Comparing Strings

    Looking for help in writing a code that will compare two names and determine if they are equal,less than,or greater than the other.Alphabetically speaking.


  2. #2
    Join Date
    Jun 2001
    Location
    Sri Lanka
    Posts
    272

    Re: Comparing Strings

    u can compare the 2 strings as
    If String1 = String2 then
    ' ......
    End if


    I can't understand, what do u mean by "Alphabetically speaking"
    If u mean the length of the string then u can get that by
    Len(String1) function
    If u give an example for the cases where Less Than & Greater Than Occur I may be able to help u.
    Srinika

    If u don't know how to Rate an answer, then Rate my answer to learn, If u know, then practice it

  3. #3
    Join Date
    Jul 2001
    Location
    Mumbai,India
    Posts
    382

    Re: Comparing Strings

    I think he wants to make a lexicographical comparison of the two strings.
    It can be done like this ..
    If String1 > String2 Then
    If String1 < String2 Then
    etc.

    So, ("apple" < "peach") will return True, while
    ("banana" < "apple") will return False.


    Regards,
    The Beret.





  4. #4
    Join Date
    Jun 2001
    Location
    Sri Lanka
    Posts
    272

    Re: Comparing Strings

    First time in my life I heard the word - lexicographical
    Srinika

    If u don't know how to Rate an answer, then Rate my answer to learn, If u know, then practice it

  5. #5
    Join Date
    Sep 2001
    Location
    Indiana
    Posts
    6

    Re: Comparing Strings

    This application will help file records alphabetically.You enter two names in txtName1 and txtName2.I have a command button named cmdCompare.I need corresponding code to determine if the two names are equal to each other.Example John Doe = John Doe or one name is less than the other.Example Al Alda is less than Zack Zeller. or one name is greater than the other.The answer will display true or false in txtName1=Name2,txtName1<Name2 or txtName1>Name2.Using the last name starting with A as the least value. Thanks


  6. #6
    Join Date
    Jul 2001
    Location
    Mumbai,India
    Posts
    382

    Re: Comparing Strings

    The word Lexicon means Dictionary and since in a dictionary all the words appear in their alphabetical order , lexicographical means alphabetical.

    P.S : There's always a first time for everything!

    Regards,
    The Beret.



  7. #7
    Join Date
    Apr 2000
    Location
    South Carolina,USA
    Posts
    2,210

    Re: Comparing Strings

    Webster defines "Lexicographical Work" as a dictionary.

    John G

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured