当前位置:编程学习 > C#/ASP.NET >>

关于if条件语句,急!

请高手帮忙看下我这个if语句有什么问题
<%
         if rs("Class")=-1 then%>
       <font color=red>教学</font>
    <%else if rs("Class")=0 then%>
        <font color=red>德育</font>
<%else%>
<font color=red>后勤</font>
<%end if%>

我改为两个条件运行就没问题(如下)

<%
         if rs("Class")=-1 then%>
       <font color=red>教学</font>
<%else%>
<font color=red>后勤</font>
<%end if%>

运行后提示

技术信息(用于支持人员)

错误类型:
Microsoft VBScript 编译器错误 (0x800A041F)
错误的 'Next'
/lis.asp, line 103
next

注:这个next 是后面的
--------------------编程问答-------------------- if rs("Class")=0 
中 rs("Class") 是你的一个方法吗?
返回值是什么如果为整数 那么比较的符号 是用两个“=”  --------------------编程问答-------------------- rs("Class") 是返回数据表中的一个值
之前是这样定义的
<td colspan="3" valign="top" bgcolor="#FFFFFF"><input name="Class" type="radio" value=-1 checked>
                          教学
                             
                            <input type="radio" name="Class" value=0>
                            德育
 
                            <input type="radio" name="Class" value=1>
                            后勤</td> --------------------编程问答-------------------- 你的else if之间不该有空格,vb script里是连在一起的,换成下面这样看看:

<% 
        if rs("Class")=-1 then%> 
      <font color=red>教学 </font> 
    <%elseif rs("Class")=0 then%> 
        <font color=red>德育 </font> 
<%else%> 
<font color=red>后勤 </font> 
<%end if%>  --------------------编程问答-------------------- 还是一样,没解决啊!请继续帮我看看 --------------------编程问答-------------------- 你把全部代码贴出来,让大家给你看看吧! --------------------编程问答-------------------- <!--#include file="conn.asp"-->
<!--#include file="ConnUser.asp"-->
<!--#include file="config.asp"-->
<!--#include file="char.inc"-->
<!--#include file="chkuser.asp" -->
<!--#include file="ChkManage.asp" -->
<%
if not(request.cookies(eChsys)("ManageKEY")="super" or request.cookies(eChsys)("ManageKEY")="typemaster" or request.cookies(eChsys)("ManageKEY")="bigmaster") then
Show_Err("对不起,您的后台管理权限不够操作!")
response.end
else
if mailmanage="1" or (request.cookies(eChsys)("ManagePurview")="99999" and request.cookies(eChsys)("purview")="99999") then

PageShowSize = 10            '每页显示多少个页
MyPageSize   = 16          '每页显示多少条文章

If Not IsNumeric(Request("page")) Or IsEmpty(Request("page")) Or Request("page") <=0 Then
MyPage=1
Else
MyPage=Int(Abs(Request("page")))
End if

set rs=server.CreateObject("ADODB.RecordSet")
rs.Source="select * from "& db_EC_LeadMail_Table &"  order by LeadMailID desc"
rs.Open rs.Source,conn,1,1
If Not rs.eof then
rs.PageSize     = MyPageSize
MaxPages        = rs.PageCount
rs.absolutepage = MyPage
total           = rs.RecordCount
%>
<html><head>
<meta name="GENERATOR" content="Microsoft FrontPage 5.0">
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<LINK href=site.css rel=stylesheet>
<title><%=copyright%><%=version%> <%=ver%> - 信箱</title>
</head>
<body topmargin="0">

<div align="center">
<table width="100%" border="1" cellpadding="3" cellspacing="0" bordercolor="#FFDFBF" bgcolor="#FFFFFF" id="AutoNumber1" style="border-collapse: collapse">
<tr class="TDtop">
<td colspan="8" height=25 class="TDtop" align="center">┊ <B>信箱</B> ┊ </td>
</tr>
<tr>


<form method="post" name="myform" action="Admin_LeadMail_Result.asp">
<td colspan=8  align=center height=25>
        <span class=top1>信件查找:</span>
        <input type="text" name="keyword" class="login_username" onMouseOver ="this.style.backgroundColor='#F3EAD5'" onMouseOut ="this.style.backgroundColor='#FFFFFF'" size=20 value="请输入标题关键字"onfocus="if (value =='请输入标题关键字'){value =''}"onblur="if (value ==''){value='请输入标题关键字'}" maxlength="50">
      <input type="submit" name="Submit" value="搜 索" class="login_username" onMouseOver ="this.style.backgroundColor='#F3EAD5'" onMouseOut ="this.style.backgroundColor='#FFFFFF'" >
</td>
</form>
</tr>
<tr>
<td colspan=8  align=center height=25>共 <%=total%> 条,当前第 <%=Mypage%>/<%=Maxpages%> 页,每页 <%=MyPageSize%> 条</td>
</tr>
<tr class="TDtop1" align="center">
<td width="5%">ID号</td>
<td width="6%">分类</td>
<td width="10%">是否公开</td>
<td width="40%">信件标题</td>
<td width="12%">信件日期</td>
<td width="15%">处理状态</td>
<td width="12%">操作</td>
</tr>
<%
for i=1 to rs.PageSize
if not rs.EOF then
topic=trim(rs("topic"))
DisplayTopic=mid(Topic,1,25)
%>
<tr bgcolor=ffffff>
<td align=center ><%=rs("LeadMailID")%></td>
<td align=center>
<%if rs("Class")=-1 then%>
<font color=red>教学</font>
<%else if rs("Class")=0 then%>
<font color=red>德育</font>
<%else%>
<font color=red>后勤</font>
<%end if%>
</td>
<td align=center><%if rs("ClassID")=0 then%><font color=red>不希望公开</font><%else%><font color=red>可以公开</font><%end if%></td>
<td align="left"><a href='ShowLeadMail.asp?LeadMailID=<%=rs("LeadMailID")%>'><%=htmlencode(DisplayTopic)%>...</a></td>
<td align=center><%=year(rs("UpdateTime")) %>-<%=Month(rs("UpdateTime")) %>-<%=Day(rs("UpdateTime")) %></td>
<td align=center>
<%if trim(rs("ReplyContent"))<>"" then %>
<font color=red >已回复</font>
<%else%>
<font color=red >未回复</font>
<%end if%>
</td>
<td align=center >
<a href=ShowLeadMail.asp?LeadMailID=<%=rs("LeadMailID")%> style="font-size: 9pt;  color: #000000; background-color: #ffffff; solid #FEEBE4" onMouseOver ="this.style.backgroundColor='#FEEBE4'" onMouseOut ="this.style.backgroundColor='#ffffff'">查看</a>
<a href=DelLeadMail.asp?LeadMailID=<%=rs("LeadMailID")%> style="font-size: 9pt;  color: #000000; background-color: #ffffff; solid #FEEBE4" onMouseOver ="this.style.backgroundColor='#FEEBE4'" onMouseOut ="this.style.backgroundColor='#ffffff'">删除</a>
</td>
</tr>
<%
rs.MoveNext
end if
next
%>
<tr>
<td colspan=8  align=center height=25>共 <%=total%> 条,当前第 <%=Mypage%>/<%=Maxpages%> 页,每页 <%=MyPageSize%> 条 
<%
url="E_LeadMailList.asp?" 
PageNextSize=int((MyPage-1)/PageShowSize)+1
Pagetpage=int((total-1)/rs.PageSize)+1
if PageNextSize >1 then
PagePrev=PageShowSize*(PageNextSize-1)
Response.write "<a class=black href='" & Url & "page=" & PagePrev & "' title='上" & PageShowSize & "页'>上一翻页</a> "
Response.write "<a class=black href='" & Url & "page=1' title='第1页'>页首</a> "
end if
if MyPage-1 > 0 then
Prev_Page = MyPage - 1
Response.write "<a class=black href='" & Url & "page=" & Prev_Page & "' title='第" & Prev_Page & "页'>上一页</a> "
end if

if Maxpages>=PageNextSize*PageShowSize then
PageSizeShow = PageShowSize
Else
PageSizeShow = Maxpages-PageShowSize*(PageNextSize-1)
End if
If PageSizeShow < 1 Then PageSizeShow = 1
for PageCounterSize=1 to PageSizeShow
PageLink = (PageCounterSize+PageNextSize*PageShowSize)-PageShowSize
if PageLink <> MyPage Then
Response.write "<a class=black href='" & Url & "page=" & PageLink & "'>[" & PageLink & "]</a> "
else
Response.Write "<B>["& PageLink &"]</B> "
end if
If PageLink = MaxPages Then Exit for
Next
if Mypage+1 <=Pagetpage  then
Next_Page = MyPage + 1
Response.write "<a class=black href='" & Url & "page=" & Next_Page & "' title='第" & Next_Page & "页'>下一页</A>"
end if
if MaxPages > PageShowSize*PageNextSize then
PageNext = PageShowSize * PageNextSize + 1
Response.write " <A class=black href='" & Url & "page=" & Pagetpage & "' title='第"& Pagetpage &"页'>页尾</A>"
Response.write " <a class=black href='" & Url & "page=" & PageNext & "' title='下" & PageShowSize & "页'>下一翻页</a>"
End if
rs.close
set rs=nothing
conn.close
set conn=nothing
%>
</td>
</tr>
</table>
</div>
</body>
</html>
<!--#include file="Admin_Bottom.asp"-->
<%else
Show_Message("暂时没有来信")
response.end
end if
else
Show_Err("对不起,该功能已经被超级系统管理员关闭,您没有权限操作!")
response.end
end if
end if%> --------------------编程问答-------------------- up.. --------------------编程问答-------------------- 技术信息(用于支持人员)

错误类型:
Microsoft VBScript 编译器错误 (0x800A041F)
错误的 'Next'
/E_LeadMailList.asp, line 103
next


浏览器类型:
Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322; 360SE) 

网页:
GET /E_LeadMailList.asp 

时间:
2009年11月15日星期日, 12:19:46 


详细信息:
Microsoft 支持  --------------------编程问答-------------------- 其实我的目的是要根据class的值不同,然后判断显示相应的字符
拜托各位啦 --------------------编程问答--------------------
引用 9 楼 xnldl 的回复:
其实我的目的是要根据class的值不同,然后判断显示相应的字符
拜托各位啦

请教楼主,有200分可用分,发贴时默认是20分,为什么改成0分呢?可用分除提问用还有什么用处呢? --------------------编程问答-------------------- 改了100分啦 --------------------编程问答-------------------- 请大家帮我解决啦,拜托! --------------------编程问答-------------------- 还有没人帮我解决下呢? --------------------编程问答--------------------

<%if rs("Class")=-1 then%> 
<font color=red>教学 </font> 
<%elseif rs("Class")=0 then%> 
<font color=red>德育 </font> 
<%else%> 
<font color=red>后勤 </font> 
<%end if%>

另外你发错版了 --------------------编程问答--------------------  <%else if rs("Class")=0 then%> 
        <font color=red>德育 </font> 
这个错了,你把这个改正就可执行了<%elseif    then  end if%> --------------------编程问答-------------------- line 103 是哪行,到web版块
next用错了 --------------------编程问答-------------------- <% 
end if '-------------少了一个end if
rs.MoveNext 
end if 
next 
%> 
补充:.NET技术 ,  ASP.NET
CopyRight © 2022 站长资源库 编程知识问答 zzzyk.com All Rights Reserved
部分文章来自网络,