Click to See Complete Forum and Search --> : Comparing Strings


Jim078
October 16th, 2001, 09:03 PM
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.

srinika
October 16th, 2001, 09:43 PM
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

Green_Beret
October 16th, 2001, 10:19 PM
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.

srinika
October 16th, 2001, 10:25 PM
First time in my life I heard the word - lexicographical
Srinika

Jim078
October 16th, 2001, 10:46 PM
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

Green_Beret
October 17th, 2001, 12:49 AM
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.

John G Duffy
October 17th, 2001, 08:39 AM
Webster defines "Lexicographical Work" as a dictionary.

John G