asp script question

S

Samir

I am try to compare more than one value to a string in my asp script ie.

<%
if strVar = "test" and strVar = "test2" and strVar = "test3" then
do some stuff
end if
%>

is there a shorter way of comparing different values to a variable?
 
M

Mark Schupp

You mean "or" don't you. The expression you have could be simplified to "if
false then" because it will never be true.

Try:

if Instr( ",test,test2,test3,", "," & strVar & ",") > 0 then
....

If you can be sure that strvar will never contain "," then you can simplify
to
If Instr(",test,test2,test3,", strVar) > 0 then
 
S

Samir

Yes thank you, I meant or.

Mark Schupp said:
You mean "or" don't you. The expression you have could be simplified to "if
false then" because it will never be true.

Try:

if Instr( ",test,test2,test3,", "," & strVar & ",") > 0 then
...

If you can be sure that strvar will never contain "," then you can simplify
to
If Instr(",test,test2,test3,", strVar) > 0 then


--
Mark Schupp
Head of Development
Integrity eLearning
www.ielearning.com
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,780
Messages
2,569,611
Members
45,276
Latest member
Sawatmakal

Latest Threads

Top