「VB.NET」Containsメソッドで文字列の部分一致判定するサンプル

構文
対象文字列.Contains(検索文字列)
StringクラスのContainsメソッドを使用して、指定した文字と文字列が部分一致しているかを判定します。

使用例

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
Module Module1
Public Sub Main()
Dim str As String = "study skill become smart"
Console.WriteLine("文字列の部分一致判定結果")
Console.WriteLine(str.Contains("become"))
Console.WriteLine(str.Contains("sss"))
Console.ReadKey()
End Sub
End Module
Module Module1 Public Sub Main() Dim str As String = "study skill become smart" Console.WriteLine("文字列の部分一致判定結果") Console.WriteLine(str.Contains("become")) Console.WriteLine(str.Contains("sss")) Console.ReadKey() End Sub End Module
Module Module1
    Public Sub Main()

        Dim str As String = "study skill become smart"

        Console.WriteLine("文字列の部分一致判定結果")
        Console.WriteLine(str.Contains("become"))
        Console.WriteLine(str.Contains("sss"))

        Console.ReadKey()

    End Sub

End Module

実行結果

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
文字列の部分一致判定結果
True
False
文字列の部分一致判定結果 True False
文字列の部分一致判定結果
True
False

 

VB.net

Posted by arkgame