我只是在使用vb的asp经典上使用IF OR运算符,但它似乎没有像我预期的那样正常工作。我需要,如果VALUES(VALUE1或VALUE2)中的哪一个的值不是0,或者两者都有(例如)1值,它将起作用。
set rsY = cn.execute ("SELECT COUNT(VALUE1) AS VALUE1, COUNT(VALUE2) AS VALUE2 FROM DUAL")
VALUE1= "1"
VALUE2= "0"
if not rsY.eof then
VALUE1= rsY("VALUE1")
VALUE2= rsY("VALUE2")
end if
set rsY = nothing
if (Cint(VALUE1) = 0) or (Cint(VALUE2) = 0) then
'code should here
else
'code should here
end if
提前感谢任何帮助
答案 0 :(得分:0)
根据我对你的多重陈述的理解,如果只有VALUE1和VALUE2 两者等于零(0)那么如果条件应该执行,否则其他条件应该被执行
if (Cint(VALUE1) = 0) AND (Cint(VALUE2) = 0) then 'please note the operator AND
'code should here
else
'code should here
end if
答案 1 :(得分:0)
Dim rsY, sql, value1, value2
sql = "SELECT COUNT(VALUE1) AS VALUE1, COUNT(VALUE2) AS VALUE2 FROM DUAL"
SET rsY = cn.execute (sql)
value1= 1 'Without ""
value2= 0
IF Not rsY.EOF Then
value1= rsY("VALUE1")
value2= rsY("VALUE2")
End If
Set rsY = nothing
If (Cint(value1) = 0) AND (Cint(value2) = 0) Then 'If Both equals zero
Response.Write("Enter in if condition");
Else 'If any of the values are different from zero
Response.Write("Enter in else condition");
End If