We help IT Professionals succeed at work.

VBScript If Statement

romsom
romsom asked
on
Hi Experts,
I'm using an if statement which is working fine, when I have only one Login (Peter)

<%If Login = "Peter" Then%>
Do This
<%Else%>
Do That
<%End If%>

What would be the syntax if I want to add Mary, George, Larry, etc.

Thank you for your help.
Comment
Watch Question

Top Expert 2015
Commented:
In vb you can do something like this...

<%If Login = "Peter"  or login="Mary" Or login="George" or Login="Larry" Then%>
Do This
<%Else%>
Do That
<%End If%>

Open in new window

Web Ninja at large
Commented:
you could use multiple OR statements in your if statement:

<%If Login = "Peter" or Login = "Mary" or Login = "George" or Login = "Larry" Then%>
Do This
<%Else%>
Do That
<%End If%>

Open in new window


or you could use a case select, which is useful if you want to have a custom action for each login

<%
select Login
       case "Peter":    Response.Write "Peter"
       case "George": Response.Write "George"
       case "Mary", "Larry": Response.Write "May or Larry"
       case else: Response.Write "no login" 
end select

Open in new window

romsomIT Developer

Author

Commented:
Thank you very much