Find a word in a string

In this example we will use the InStr function to try and locate a word in a string . The syntax of the InStr function is as follows

InStr ( string , text )

This finds the word text in the string and reports back the number of the first character where the word is find

Here is an example

<%
Dim strText
'here is our string
strText = "This is our sample text to be searched"
'we will look for the word sample
strSearch = InStr(strText , "sample")
'display the results
Response.Write strSearch
%>

 

Sponsors