StrCompare

2つの文字列をアルファベット順に比較します。

Result := StrCompare(String1, String2 , CaseSense)

パラメータ

String1, String2

型:文字列

比較する文字列。

CaseSense

型:String or Integer (boolean)

If omitted, it defaults to Off. それ以外のときは、次のいずれかの値を指定します:

On または 1 (true):比較は大文字と小文字を区別する。

Off または 0 (false):The comparison is not case-sensitive, i.e. the letters A-Z are considered identical to their lowercase counterparts.

Locale: The comparison is not case-sensitive according to the rules of the current user's locale. 例えば、英語や西欧のロケールでは、A~Zの小文字だけでなく、ÄやÜなどの非ASCII文字も小文字と同じように扱われることがほとんどです。Localeは、比較する文字列の性質によって、Offの1~8倍遅くなります。

Logical: Like Locale, but digits in the strings are considered as numerical content rather than text. For example, "A2" is considered less than "A10". However, if two numbers differ only by the presence of a leading zero, the string with leading zero may be considered less than the other string. 正確な動作はOSのバージョンによって異なる場合があります。

戻り値

型:整数

String1String2の関係を示すために、この関数は以下のいずれかを返す:

2つの文字列間の特定の関係をチェックするには、結果を0と比較する。事例:

a_less_than_b := StrCompare(a, b) < 0
a_greater_than_or_equal_to_b := StrCompare(a, b) >= 0

備考

この関数はソートコールバックによく使われる。

Sort, VerCompare

大文字小文字を区別しない比較と区別する比較の違いを示す。

MsgBox StrCompare("Abc", "abc") ; Returns 0
MsgBox StrCompare("Abc", "abc", true) ; Returns -1