• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 221
  • Last Modified:

If statement in Classic ASP

Hi Experts,
I would like to add two more conditions to the following if statement:
<%If rs("LevelOfDiscipline")<>"Informal Conversation" Then%>
Besides "Informal Conversation" I would also like to add "Coaching" and "Counseling".
What is the correct format?

I tried
not in ("Informal Conversation", "Coaching", "Counseling")
but it didn't work.

Thank you for your help.
  • 2
2 Solutions
David LeeCommented:
I recommend switching from an IF statement to a CASE statement.  Something like

    Select Case rs("LevelOfDiscipline").value
        Case "Informal Conversation", "Coaching", "Counseling")
            'Your code goes here'
    End Select

Open in new window

Big MontySenior Web Developer / CEO of ExchangeTree.org Commented:

<%If rs("LevelOfDiscipline")<>"Informal Conversation" or rs("LevelOfDiscipline") = "Coaching" or rs("LevelOfDiscipline") = "Counseling"  Then%>
romsomAuthor Commented:
Thank you all.
DevilFan, I was trying to customize your solution, but unfortunately I couldn't do it.
David LeeCommented:

There was a typo in the code.  There shouldn't have been a parenthesis at the end of line 3.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now