Monday, 12 March 2012

vb.net string contains()?


How to string contains() in vb.net?
I this tutorial you can learn how to check string contains (check the given string is there are not) or not, syntax for to check string is
String.contains(string str)
Here : Stràgiven string
String à string data type
Ex: str = string.contains(example)
To check word “example” whether there or not
  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 ststring As String = TextBox1.Text
        Dim ndbstring As String = TextBox2.Text
        If ststring.Contains(TextBox2.Text) Then
            MessageBox.Show("the given string is in 1st tstring: ")
        Else
            MessageBox.Show("the given string is not there in 1st string:")
        End If
       
    End Sub
End Class



 Output: