ASP 经典 VB 如果条件不工作
ASP Classic VB if condition not working
我只是使用 vb 在 asp classic 上使用 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
在此先感谢您的帮助
根据我对你的多个陈述的理解,如果只有 VALUE1 和 VALUE2 两者 等于 zero(0) 那么如果条件应执行,否则应执行Else条件
if (Cint(VALUE1) = 0) AND (Cint(VALUE2) = 0) then 'please note the operator AND
'code should here
else
'code should here
end if
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
我只是使用 vb 在 asp classic 上使用 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
在此先感谢您的帮助
根据我对你的多个陈述的理解,如果只有 VALUE1 和 VALUE2 两者 等于 zero(0) 那么如果条件应执行,否则应执行Else条件
if (Cint(VALUE1) = 0) AND (Cint(VALUE2) = 0) then 'please note the operator AND
'code should here
else
'code should here
end if
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