Tuesday, 13 March 2012

vb.net string Endswith()?

How to string Endswith() in vb.net?
I this tutorial you can learn how to check the string ends with (check string is ends with some word or not) specified string
String.endswith(string  end_word) As boolean
Ex: str.endswith(“ program”)
It will returns “program” is the endwith() str string. It will shows as true or false
 To do this program following steps to be followed
Open Microsoft visual studio 2010 or any older version also may differ commands
Open file new project(ctrl+shift+n)àselect windows form applicationà rename as you wish
Drag and drop two label, textbox, and one button
Label1.textà1st string
Label2.textà2nd string
Copy and paste the following code
Public Class Form1

    Private SubButton1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) HandlesButton1.Click
        Dim firststring As String = TextBox1.Text
        Dim secondstring As String = TextBox2.Text
        If firststring.EndsWith(TextBox2.Text) = True Then
            MessageBox.Show("the first string is endswith   "& TextBox2.Text)
            MessageBox.Show("the first string is not endswith  "& TextBox2.Text)

        End If
    End Sub
End Class