关于asp在线考试的一个小问题。请教大家指点。非常感谢

来源:百度知道 编辑:UC知道 时间:2024/06/14 07:57:24
<%
Dim rs ,strSql, score
Set rs = Server.CreateObject("ADODB.RecordSet")
strSql = "SELECT * FROM test "
rs.open strSql,conn,3,3
rsCount=0
ycorrect=0
Response.Write "正确答案:"

Do while not rs.eof
Response.Write rs("ans") ’读出数据库中的正确答案

rsCount=rsCount + 1
if Request.Form("rsCount")=rs("ans") then
ycorrect=ycorrect + 1
end if

rs.movenext
loop

Response.Write "<br> 你的答案:"

for i=1 to Request.Form.Count - 1
Response.Write Request.Form(i) '显示提交的答案
score=int(ycorrect/rscount*100) '计算分数
next

Response.Write "<br> "
Response.Write "你的成绩为:"&score
Response.Write "<br> "
if score <= 60 then Response.Write "你不及格!"&"<br>"
if score >= 60 and score <= 80 then Response.Writ

score=int(ycorrect/rscount*100) '计算分数
这一句的写法不正确,改成:score=int(ycorrect/rscount)*100
试试看。依照你原来的写法是把100做分母了,算出来的一定是小于1的数,取整以后自然就是0了。
--------------------
抱歉!上面的写法有误。
因为ycorrect的值永远不能大于rscount,所以的出来的数永远小于等于1,取整以后就等于0了。写成100*ycorrect/rscount再试试