VBScriptのStrComp関数

定義と用法

StrComp関数は二つの文字列を比較し、比較結果を示す値を返します。

StrComp関数は以下の値を返します:

  • -1 (如果 string1 < string2)
  • 0 (如果 string1 = string2)
  • -1 (string1 < string2 の場合)
  • 0 (string1 = string2 の場合)

1 (string1 > string2 の場合)

Null (string1 または string2 が Null の場合)
構文 StrComp(string1,string2[,compare])
パラメータ string1
説明 string1
string2

必須。文字列表現。

compare

  • オプション。使用する文字列比較の種類を指定します。デフォルトは 0 です。Optional. Specifies the string comparison to use. Default is 0
  • 使用可能な値:

0 = vbBinaryCompare - 二進比較を実行

1 = vbTextCompare - テキスト比較を実行

出力:

0

例 2

document.write(StrComp("VBScript","vbscript"))

出力:

-1

例 3

document.write(StrComp("VBScript","vbscript",1))

出力:

0