Like operator in VB.NET

This blog defines the like operator in VB.NET

Like operator

The Like operator is used for compare two string. If string matches pattern, result is True; if there is no match, result is False. If both string and pattern are an empty string. the result is True. Otherwise, if either string or pattern is an empty string, the result is False.

General Syntax

res = string Like pattern
res
Required. Any Boolean variable. The result is a Boolean value indicating whether or not the string matches the pattern.
string
Required. Any String expression.
pattern
Required. Any String expression conforming to the pattern-matching conventions described in Remarks.

For example

Module Module1

    Sub Main()

        Dim s As String

        s = "VB.Net"

        If s Like "?B.Net" Then

    Console.WriteLine("'VB.Net' is Like '?B.Net'")

    End Sub

End Module

 

OUTPUT

 like1.gif