Tag Archives: check string

Check for a specific String in a String in VB.NET

This works for VB.NET and higher.


        'Will check a string to see if it contains a specified string.
        'The string that will be searched.
        Dim str As String = "This string has some text"
        'The string to find.
        Dim i As Integer = str.IndexOf("string")
        'If it returns -1 it means that no matches for the specified string was found.
        If Not i = -1 Then

            MessageBox.Show("Yeps, that string is in here!")


            MessageBox.Show("No, the string is not in here!")

        End If