Like keyword to comparison in VB.NET

This article is about the Like keyword functionality in Vb.NET
  • 2433

In this article I explain the Like keyword functionality in VB.NET. Like keyword is used to compare the two values whether both of the values entered by user at run time or already specify in the program. I take a example to demonstrate the working below example explain you to how you can set a pattern and than enter a value and compare both of them on console screen.

Examples

    Module Module1
        Sub Main()
            Dim UserInput As String
            Dim
Pattern As String
            Dim
Match As String
            System.Console.Write("Please Enter A Pattern:")
            UserInput = System.Console.ReadLine()
            Pattern = UserInput
            System.Console.Write("Please Enter A value To Compare With Pattern:")
            UserInput = System.Console.ReadLine()
            Match = UserInput
            If Match Like Pattern Then
                System.Console.WriteLine(Match & " Matched with " & Pattern)
            Else
                System.Console.WriteLine(Match & " did not Match with " & Pattern)
            End If
                Console.ReadLine()
        End Sub
    End
Module

OUTPUT

 8.gif

Categories

More Articles

© 2019 DotNetHeaven. All rights reserved.