Link to home
Start Free TrialLog in
Avatar of Bill Henderson
Bill HendersonFlag for United States of America

asked on

classic aspvb syntax question

Hi,

I have an old asp site that I need to modify. We have a menu item that shows under a certain condition with a usertype field:

  <% IF Session("UserType") = 1 OR Session("UserType") = 7 THEN %> 

Open in new window


and then we show the menu item.

We recently modified a database field so that a single user record can be assigned multiple types in a comma delimited list. So instead of UserType=1, for our condition, we need to check if Session("UserType") contains 1 in a comma delimited list.

assuming users will have values like 1,7,8 or 1,3,7 how can I scan and confirm a "contains" condition in asp vb?

Thank you

Bill
ASKER CERTIFIED SOLUTION
Avatar of Gary
Gary
Flag of Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Bill Henderson

ASKER

Thanks All - now Gary's solution is clearly the simplest, and right now all values are 1 - 8, but just to clarify, the second example assumes the number MUST be greater than 9?

So truly if we get to 10 user types, we need to use Pradas or Rainer's solutions?
Hi,
Gary`s is the quickest one - but hard to read and you have always to add the "," before and after your session variable. This will work for any number but it could be not as error save as Padas/my solution due to the extras you have to add.

Padas solution is the right one in terms of best practices as it creates the array with the distinct values and then runs the compare.

My extension to Padas solution just make it usable for any check you want to run - check for 5 or 10 or ...

Just my 2ct
Rainer
OK thx - I have another question related to this that I will post right now, to not abuse my points. =)
Thanks for the help
Don't actually see a problem with adding a comma, it just makes the number distinct to do an instr check