注册 登录
编程论坛 ASP技术论坛

这样的判断语句是啥意思?

sylknb 发布于 2010-04-02 14:55, 712 次点击
if not rsfinds.eof then
else
执行语句
endif
上面条件为真,后面没有内容,else可写可不写吗?不是没有作用吗?

[ 本帖最后由 sylknb 于 2010-4-2 14:57 编辑 ]
8 回复
#2
sky2222010-04-02 15:09
else没内容可以省略的啊
#3
sylknb2010-04-02 15:11
else内容,then 后面没有内容。
#4
sky2222010-04-02 15:48
那else不能省略的。

要不然这个判断就没意义了
#5
sylknb2010-04-02 17:09
我的意思是if not rsfinds.eof then     ‘此后面没有要执行的语句
else
执行语句
endif
既然这样就不要else,直接if not rsfinds.eof then  
                        执行语句
                          endif
   
摘自书中:
set rsfinds=conn.execute("select * from report where 试卷id="&testid&" and 学生id="&session("id")&" and (是否补考=True and  补考成绩=0)")
if not rsfinds.eof then
else
sqlin="insert into report (id,试卷id,学生id,分数) values("&qi&","&testid&","&session("id")&",0)"
set rsin=conn.execute(sqlin)
end if


[ 本帖最后由 sylknb 于 2010-4-2 17:12 编辑 ]
#6
sky2222010-04-08 09:33
程序代码:
set rsfinds=conn.execute("select * from report where 试卷id="&testid&" and 学生id="&session("id")&" and (是否补考=True and  补考成绩=0)")
if rsfinds.eof then
sqlin="insert into report (id,试卷id,学生id,分数) values("&qi&","&testid&","&session("id")&",0)"
set rsin=conn.execute(sqlin)
end if
这样应该就好了,你去调试一下
#7
zzy_4202010-04-10 23:41
if not rsfinds.eof then     ‘此后面没有要执行的语句
else
执行语句
endif

if rsfinds.eof then
执行语句
endif

两段代码执行的结果是一样的,只是写法不同而已。

它们都是判断记录是否已经到了最后一条记录的后面,如果为真 就执行语句(执行插入操作),否则不做处理.
#8
work0012010-04-11 08:54
呵呵。
#9
sylknb2010-04-14 18:15
多种写法,特别那种不常规写法对刚学者实才有时有点莫名其妙
1