Forums

ASP

This topic is locked

Help with an IF... THEN statement

Posted 19 Feb 2003 23:34:09
1
has voted
19 Feb 2003 23:34:09 Phil Grimpo posted:
In SQL I am able to do a phrase like: SELECT * FROM table WHERE x IN (1,2,3)

How can I do this in an IF THEN statement? I want to do something like:

IF variable IN (1,2,3,4) THEN

Any ideas? This syntax does not work.

Thanks for the help!

-Grimps

Phil Grimpo
Executive Director
Inspirmedia

Replies

Replied 20 Feb 2003 00:55:42
20 Feb 2003 00:55:42 Owen Eastwick replied:
Try:

variable = "3"
If InStr("1, 2, 3, 4", variable) <> 0 Then..

However bear in min that 3 will match with 3, 13, 23, 30, 31, 32 etc...


Alternativley try something like this:

<%
variable = 3
varArray = Split ("1, 2, 3, 4", ", "
For i = 0 to Ubound(varArray)' AND variable <> varArray(i)
If variable = CInt(varArray(i)) then
Response.Write("Hello World!"
Exit For
End If
Next
%>


Regards

Owen.

-------------------------------------------------------------------------------------------
Used programming books and web development software for sale (UK only): www.tdsf.co.uk/tdsfdemo/Shop.htm

Developer services and tutorials: www.drdev.net

Multiple Parameter UD4 / Access 2000 Search Tutorial: www.tdsf.co.uk/tdsfdemo/
Replied 23 Feb 2003 12:07:10
23 Feb 2003 12:07:10 Jørgen Emerslund replied:
<%

If In=1 OR In=2 or In=3 oR IN=4 Then
' Do something
End if

%>

Like that maybe?

Reply to this topic