Strings.StrComp メソッドとは? わかりやすく解説

Strings.StrComp メソッド

文字列比較結果基づいて -1、0、または 1 を返します

名前空間: Microsoft.VisualBasic
アセンブリ: Microsoft.VisualBasic (microsoft.visualbasic.dll 内)
構文構文

Public Shared Function StrComp
 ( _
    String1 As String, _
    String2 As String, _
    <OptionalAttribute> Optional Compare As
 CompareMethod = CompareMethod.Binary _
) As Integer
Dim String1 As String
Dim String2 As String
Dim Compare As CompareMethod
Dim returnValue As Integer

returnValue = Strings.StrComp(String1, String2, Compare)
public static int StrComp
 (
    string String1,
    string String2,
    [OptionalAttribute] CompareMethod Compare
)
public:
static int StrComp (
    String^ String1, 
    String^ String2, 
    [OptionalAttribute] CompareMethod Compare
)
public static int StrComp
 (
    String String1, 
    String String2, 
    /** @attribute OptionalAttribute() */ CompareMethod Compare
)
public static function StrComp
 (
    String1 : String, 
    String2 : String, 
    Compare : CompareMethod
) : int

パラメータ

String1

必須任意の有効な String 型の式。

String2

必須任意の有効な String 型の式。

Compare

省略可能。文字列比較種類指定しますCompare省略されている場合Option Compare 設定により比較種類決定します

戻り値
String1String2 の前を並べ替える場合、StrComp は -1 を返しますString1String2等し場合、StrComp は 0 を返しますString1String2後ろ並べ替える場合、StrComp は 1 を返します

解説解説
使用例使用例

この例では、StrComp 関数使用して文字列比較結果返してます。3 つ目の引数省略した場合Option Compare ステートメント定義され比較種類、またはプロジェクト既定比較種類実行されます。

' Defines variables.
Dim TestStr1 As String =
 "ABCD"
Dim TestStr2 As String =
 "abcd"
Dim TestComp As Integer
' The two strings sort equally. Returns 0.
TestComp = StrComp(TestStr1, TestStr2, CompareMethod.Text)
' TestStr1 sorts after TestStr2. Returns -1.
TestComp = StrComp(TestStr1, TestStr2, CompareMethod.Binary)
' TestStr2 sorts before TestStr1. Returns 1.
TestComp = StrComp(TestStr2, TestStr1)
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照


このページでは「.NET Framework クラス ライブラリ リファレンス」からStrings.StrComp メソッドを検索した結果を表示しています。
Weblioに収録されているすべての辞書からStrings.StrComp メソッドを検索する場合は、下記のリンクをクリックしてください。
 全ての辞書からStrings.StrComp メソッド を検索

英和和英テキスト翻訳>> Weblio翻訳
英語⇒日本語日本語⇒英語
  

辞書ショートカット

すべての辞書の索引

Strings.StrComp メソッドのお隣キーワード
検索ランキング

   

英語⇒日本語
日本語⇒英語
   



Strings.StrComp メソッドのページの著作権
Weblio 辞書 情報提供元は 参加元一覧 にて確認できます。

   
日本マイクロソフト株式会社日本マイクロソフト株式会社
© 2025 Microsoft.All rights reserved.

©2025 GRAS Group, Inc.RSS