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 biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

"in"?

Status
Not open for further replies.

disord3r

Programmer
Apr 12, 2002
189
US
Maybe "in" doesn't do quite what I think it does.

I'm trying to set a variable based on the value of another variable. If the value of the first variable is in a specified list, then the value of the second variable should be set.

For instance, lets say

userinput = "apple"

if userinput in ("carrot", "celery", "tomato") then
type = "vegetable"
elseif userinput in ("apple", "peach", "pear") then
type = "fruit"
end if

That's the basic concept, but I haven't gotten it to work quite like that. I think I've been working with PHP too much. :)

Unfortunately, when searching for something like "in", you don't get too much help from search engines, if they even decide allow "in" as a keyword. But there's no doubt another asp-specific way to do this, I just don't know what it is.

The alternative is to have each of those specified values in an array, and loop through them to check each against the userinput. That seems like a roundabout way of doing it, but if that's what I have to resort to, then I guess I shall.

Anyone?
 
Nevermind the reserved variable names I chose for this whole operation. :)
 
Dunno if Instr would work for you

tempstr="carrot celery tomato"
if instr(tempstr,userinput)>0 then type="vegetable" Saturday 12.00
im6.gif
im2.gif
im2.gif
20.00
im5.gif
im4.gif
im7.gif
3.00am
im8.gif
Sunday [img http
 
You could use the
Code:
Select myVar
 Case ("carrot", "celery", "tomato")

 case else

end select
Thanks,

Gabe
 
It may be
Code:
Case "carrot", "celery", "tomato"

I can't remember if you use () or not.

Thanks,

Gabe
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top