PDA

Click to See Complete Forum and Search --> : Can the expressions AND and OR go together in a IF statement in vbscript


Oct 9th, 2000, 04:11 AM
Hi there, I'm trying to make a sub function accessible only if multiple conditions are met. If I only use multiple AND's or multiple OR's at once it works fine but when I try to combine them it won't work. I wonder if I'm using the correct syntax. This is what I tried:

If (selected="Monday") And (id="A1" OR id="A2") then
{do certain things}
End If


Looks like I can't use the brackets but how else can it be done? Please send your suggestions.
Thank you for your time.

Ober
Oct 9th, 2000, 04:17 AM
Private Sub Command1_Click()
Dim a
Dim b
Dim c

a = "YES"
b = "NO"
c = "NO"

If a = "YES" And b = "YES" Or c = "YES" Then
MsgBox "Yup for A and maybe B or C"
End If

End Sub

'I test this and it seemd to work okay

Mark Sreeves
Oct 9th, 2000, 04:41 AM
Hardballa

(I'm assuming you are using the VBScript in an Active Server Page)

Your code looks ok to me!

I just tried this and it was OK.

Are you sure your values for selected, A1 and A2 are being set correctly?




<HTML>
<HEAD>

</HEAD>
<BODY>
<%
dim selected
dim id


selected="Monday"
'selected="Tuesday"
'id="A2"
id="A1"

If (selected="Monday") And (id="A1" OR id="A2") then
response.write("conditions met")

else
response.write("conditions NOT met")
End If




%>

</form>
</BODY>
</HTML>