Like operator in VB.NET

By Rohatash Kumar Mar 24, 2011
This blog defines the 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
Required. Any Boolean variable. The result is a Boolean value indicating whether or not the string matches the pattern.
Required. Any String expression.
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




Rohatash Kumar
Rohatash Kumar

Normal 0 false false false EN-AU X-NONE X-NONE I am a Microsoft .NET software Developer and author and C# Corner MVP. I hold Masters degree i... Read more