PDA

View Full Version : Proper Syntax indexOf()


JoeP
09-09-2002, 04:16 PM
Would someone advise me as to the correct syntax of a string test.

I get the following error:


Microsoft VBScript runtime error '800a01a8'
Object required: 'This is a Test for The occurrence of B in this string.'



With this:
<%
str = "This is a Test for The occurrence of B in this string."
if (str.indexOf(B) > -1) Then
Response.write("String Contains B")
else
Response.write("String Does Not Contain B")
end If
%>


Thank you.

allida77
09-09-2002, 04:30 PM
Are you using jscript, if so I have no idea. If you are using vbscript try the InStr() (http://www.devguru.com/Technologies/vbscript/quickref/instr.html) function.

JoeP
09-09-2002, 04:39 PM
THANK YOU!

using vbscript. I changed to:

<%
str = "This is a Test for B"

if inStr(str,"B") > 0 Then
Response.write("String Contains B")
else
Response.write("String Does Not Contain B")
end If
%>

Works fine!!! :thumbsup: