Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Is there a "like" function 1

Status
Not open for further replies.

cramd

Programmer
Joined
Mar 28, 2001
Messages
214
Location
US
This VBScrip is included on an html form. I'm searching for a function that will allow me to do a "like" statement. I receive a runtime error with the following:

<%
If Request.Form(&quot;IPMName&quot;) like &quot; and &quot; Then
Response.Write &quot;2&quot;
Else
Response.Write &quot;1&quot;
End if %>

Suggestions would be appreciated!

 
VBScript does not support the LIKE operator but there are ways around this. Check this site and it will show you examples of doing this comparison.
I may not get it the 1st or 2nd time,
but how sweet that 15th time can be.
 
I wrote a example if you need to refernce one.
you would use it like this in your .asp
<%
x = Request.Form(&quot;IPMName&quot;)
if Instr(1, X, &quot;and&quot;) > 0 then
msgbox &quot;IPMName is like AND&quot;
end if
%>
here's client side example:
<html>
<head>
<script language=&quot;Vbscript&quot;>
sub check()
x = one.box.value
if Instr(1, X, &quot;and&quot;) > 0 then
msgbox &quot;IPMName is like AND&quot;
end if
end sub
</script>
</head>
<body>
<form name=&quot;one&quot;>
<input type=&quot;text&quot; name=&quot;box&quot;>
<input type=&quot;button&quot; onClick=&quot;check()&quot;>
</form>
</body>
</html> I may not get it the 1st or 2nd time,
but how sweet that 15th time can be.
 
I toy with VB more than I have of VBScript or HTML--so this is what I have changed my code to read, still having problems. --But thanks for that website, it is helpful...

<%
If Request.Form(&quot;IPMName&quot;) inStr &quot; and &quot; Then
Response.Write &quot;2&quot;
Else
Response.Write &quot;1&quot;
End if %>

Nor does this work:
<%
If inStr (Request.Form(&quot;IPMName&quot;)) &quot; and &quot; Then
Response.Write &quot;2&quot;
Else
Response.Write &quot;1&quot;
End if %>

Do I need an HTML lesson???
 
try this

<%
x = Request.Form(&quot;IPMName&quot;)
if Instr(1, X, &quot;and&quot;) > 0 then
Response.Write &quot;2&quot;
Else
Response.Write &quot;1&quot;
End if
% I may not get it the 1st or 2nd time,
but how sweet that 15th time can be.
 
that response.write is backwards from what you want I think
I think you want to have 1 if it is like and 2 not then it should look like this

if Instr(1, X, &quot;and&quot;) > 0 then
Response.Write &quot;1&quot;
Else
Response.Write &quot;2&quot;

I may not get it the 1st or 2nd time,
but how sweet that 15th time can be.
 
That will do it... Thanks!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top