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
Syntax:
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
Step1:
Open Microsoft visual studio 2010 or any older version also may differ commands
Step2:
Open file new project(ctrl+shift+n)àselect windows form applicationà rename as you wish
Step3:
Drag and drop two label, textbox, and one button
Label1.textà1st string
Label2.textà2nd string
Buttonàcheck
Step4:
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)
        Else
            MessageBox.Show("the first string is not endswith  "& TextBox2.Text)

        End If
    End Sub
End Class


 Output:


No comments:

Post a Comment