VB instr

In VB, InStr(string1,string2[,CompareMethod]) is used to find a string in another string. It returns the position of the first match.
-string1 is the string being searched.
-string2 is the string sought
-CompareMethod is an optional argument. I takes one of the two constant values--CompareMethod.Binary or CompareMethod.Text. If you specify CompareMethod.Binary, the comparison is case-sensitive. This means that ab is not the same as Ab, aB, or AB. By using CompareMethod.Text, the comparison is case-insensitive. If the string2 is not in string1, the function returns 0. Otherwise, it returns the position of the first match of string2

in string1.
   Sub Main()
     Dim str1 As String = "VB programming language"
     Dim str2 As String = "Programming"
     Dim pos = InStr(str1, str2, CompareMethod.Binary)
     If Not (pos = 0) Then
        MsgBox(str2 & " is found at position " & pos & " in " & str1 & ".")
        MsgBox(str2 & " is not found in " & str1 & ".")
     End If

   End Sub

Posted by: Dara | post date: 02-15-2013 | Subject: VB.NET Programming Language

This website intents to provide free and high quality tutorials, examples, exercises and solutions, questions and answers of programming and scripting languages:
C, C++, C#, Java, VB.NET, Python, VBA,PHP & Mysql, SQL, JSP, ASP.NET,HTML, CSS, JQuery, JavaScript and other applications such as MS Excel, MS Access, and MS Word. However, we don't guarantee all things of the web are accurate. If you find any error, please report it then we will take actions to correct it as soon as possible.