Use EndWith method in Windows Forms using VB.NET

In vb.net String.EndWith method determines whether the specified string ends with the specified char pattern or not.
  • 2022
Download Files:
 

In VB.NET String.EndWith() method determines whether the specified string ends with the specified char pattern or not. It returns the Boolean value true or false based on the result whether the ending string match the specified string pattern. If string matches, true is returned otherwise false is returned.

Syntax

System.String.EndsWith(String suffix) as Boolean

 Public Class Form1
    Public Sub New()
        InitializeComponent()
    End Sub
    Private Sub Button1_Click_1(sender As System.Object, e As System.EventArgs) Handles Button1.Click
        If TextBox1.Text.EndsWith(TextBox2.Text) = True Then
            MessageBox.Show("The String end with " + TextBox2.Text)
        Else
            MessageBox.Show("The String does not end with " + TextBox2.Text)
        End If
    End Sub

End
Class
 

It starts pattern matching from right side to left side. In addition you can match the string with case sensitive or insensitive using additional parameter of overloaded methods of EndWith method. If arguments return null value, it through exception is System.ArgumentNullException.

Output

Form.gif

When you click on compare button you will get a MessageBox that represent the string end with Clark.

output.gif

Categories

More Articles

© 2019 DotNetHeaven. All rights reserved.