Help | Site Map
Connecting Tech Pros Worldwide
 
 
LinkBack Thread Tools
  #1  
Old July 19th, 2005, 02:20 PM
Samir
Guest
 
Posts: n/a
Default asp script question

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?


  #2  
Old July 19th, 2005, 02:20 PM
Curt_C [MVP]
Guest
 
Posts: n/a
Default Re: asp script question

not really, it's 3 different compares

--
Curt Christianson
Owner/Lead Developer, DF-Software
Site: http://www.Darkfalz.com
Blog: http://blog.Darkfalz.com


"Samir" <Samir@hotmail.com> wrote in message
news:ui00Lc2bEHA.3480@TK2MSFTNGP11.phx.gbl...[color=blue]
> 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?
>
>[/color]


  #3  
Old July 19th, 2005, 02:20 PM
Mark Schupp
Guest
 
Posts: n/a
Default Re: asp script question

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


"Samir" <Samir@hotmail.com> wrote in message
news:ui00Lc2bEHA.3480@TK2MSFTNGP11.phx.gbl...[color=blue]
> 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?
>
>[/color]


  #4  
Old July 19th, 2005, 02:20 PM
Samir
Guest
 
Posts: n/a
Default Re: asp script question

Yes thank you, I meant or.

"Mark Schupp" <mschupp@ielearning.com> wrote in message
news:%236FXu$3bEHA.4092@TK2MSFTNGP10.phx.gbl...[color=blue]
> You mean "or" don't you. The expression you have could be simplified to[/color]
"if[color=blue]
> 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[/color]
simplify[color=blue]
> to
> If Instr(",test,test2,test3,", strVar) > 0 then
>
>
> --
> Mark Schupp
> Head of Development
> Integrity eLearning
> www.ielearning.com
>
>
> "Samir" <Samir@hotmail.com> wrote in message
> news:ui00Lc2bEHA.3480@TK2MSFTNGP11.phx.gbl...[color=green]
> > 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?
> >
> >[/color]
>
>[/color]


 

Bookmarks

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over network members.
Post your question now . . .
It's fast and it's free

Popular Articles