(Formerly known as global function StrCaseComp, which is now obsolete)
(Formerly known as global function StrComp, which is now obsolete)
String.CompareTo(string str2, optional bool caseSensitive)
Compares the specified string to STR2. caseSensitive determines whether "Dog" and "dog"
are equivalent; case sensitivity is off by default.
Returns 0 if the strings match, a number less than 0 if this string is earlier in the alphabet than STR2,
and a number greater than 0 if this string is later in the alphabet than STR2.
TIP: To do a case-sensitive comparison of two strings, it's easier to just use the == operator.
Example:
String mytext = "Hello";
if (mytext.CompareTo("hello") == 0) {
Display("Strings match with case sensitivity off!");
}
else {
Display("Strings don't match with case sensitivity off!");
}
if (mytext == "hello") {
Display("Strings match with case sensitivity on!");
}
else {
Display("Strings don't match with case sensitivity on!");
}
will display "Strings match with case sensitivity off!", and then "Strings don't match with case sensitivity on!".
|