ARTICLE

Use EndWith method in Windows Forms

Posted by Gurjeet Singh Articles | Visual Basic Language June 21, 2011
In vb.net String.EndWith method determines whether the specified string ends with the specified char pattern or not.
Download Files:
 
Reader Level:


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

Figure 1

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

output.gif

Figure 2

Login to add your contents and source code to this article
share this article :
post comment
 
Become a Sponsor
PREMIUM SPONSORS
  • ceTE software specializes in components for dynamic PDF generation and manipulation. The DynamicPDF™ product line allows you to dynamically generate PDF documents, merge PDF documents and new content to existing PDF documents from within your applications.
    Finally – a virtual platform that delivers next-generation Windows Server 2008 Hyper-V virtualization technology from a managed hosting partner you can truly depend on. Visit www.maximumasp.com/max for a FREE 30 day trial. Hurry offer ends soon. Climb aboard the MaxV platform and take advantage of High Availability, Intelligent Monitoring, Recurrent Backups, and Scalability – with no hassle or hidden fees. As a managed hosting partner focused solely on Microsoft technologies since 2000, MaximumASP is uniquely qualified to provide the superior support that our business is built on. Unparalleled expertise with Microsoft technologies lead to working directly with Microsoft as first to offer IIS 7 and SQL 2008 betas in a hosted environment; partnering in the Go Live Program for Hyper-V; and product co-launches built on WS 2008 with Hyper-V technology.
6 Months Free & No Setup Fees ASP.NET Hosting!
Become a Sponsor