类型不匹配: 'cint'问题!

stone_0_1 2005-03-26 07:28:39
<!--#include file="dbconn.asp"-->
<!--#include file="config/config.asp"-->
<HTML>
<HEAD>
<TITLE><%=title%></TITLE>
<META content="text/html; charset=gb2312" http-equiv=Content-Type>
<link rel="stylesheet" type="text/css" href="css/index1.css">
<link rel="stylesheet" type="text/css" href="css/toolbar2.css">
<SCRIPT lanuage="javascript">
<!-- Hide
function checkdata()
{
if(document.test.chapter.value=="")
{
alert("请题目所属章节!");
return false;
}
if(document.test.num.value=="")
{
alert("题目数量不能为空!");
return false;
}
if (isNaN(document.test.num.value) )
{
alert("您填写的题目数量恐怕不正确!");
return false;
}
else if(document.test.num.value.length >2)
{
alert("您填写的题目数量恐怕不正确!");
return false;
}
}
// -->
</SCRIPT>
<META content="Microsoft FrontPage 4.0" name=GENERATOR>
<base target="_self">
</HEAD>
<BODY background="image/A-bg.gif" leftMargin=0 topMargin=0>
<!--#include file="config/title.asp"-->
<!--#include file="config/logo.asp"-->
<table align=center border=0 cellpadding=0 cellspacing=0 class=c width=760 height="35">
<tr>
<td height="13" width="177" valign="middle" align="center">现在位置:<a href="index.asp">首页</a>—测验 </td>
<td height="245" width="1" valign="middle" align="center" rowspan="3" >
<%chapterid=trim(request.form("chapter"))
num=cint(trim(request.form("num")))
RANDOMIZE
K=INT(6*RND)+1
dim order(11)
sql1="select * from 测验"
set rs1=conn.execute(sql1)
FOR i=0 TO RS1.Fields.Count-1
order(i)=RS1(i).Name
NEXT
if chapterid<>"" then
if chapterid="all" then
sql="select top "&num&" * from 测验 order by "&order(k)&" desc"
else
sql="select top "&num&" * from 测验 where 教程编号="&chapterid&" order by "&order(k)&" desc"
end if
Set rs= Server.CreateObject("ADODB.Recordset")
rs.open sql,conn,3,2
if rs.eof then%>
<td height="13" width="674" valign="middle" align="center"></td>
<tr>
<td height="35" width="177" valign="middle" align="center"></td>
<td height="232" width="674" valign="top" align="center" rowspan="2">本章没有题目</td>
</tr>
<%else%>
<td height="13" width="674" valign="middle" align="center">
<form name=forms>
<div align=center>
<%
if chapterid="all" then
response.write "您选择了 全部题目 共"&num&"题"
else
sql5="select * from 教程 where 教程编号="&chapterid&""
set rs5=conn.execute(sql5)
response.write "您选择了 "&rs5("章节")&" "&rs5("标题")&" 共"&num&"题"
end if%>
<span class="unnamed1">考试时间:
<input type=text name=input1 size=9>
<script language=javascript>
<!--
var sec=0;var min=0;var hou=0;flag=0;idt=window.setTimeout("update();",1000);function update(){sec++;if(sec==60){sec=0;min+=1;}if(min==60){min=0;hou+=1;}if((min>0)&&(flag==0)){flag=1;}
document.forms.input1.value=hou+"时"+min+"分"+sec+"秒";idt=window.setTimeout("update();",1000);}
//-->
</script>
</span></div>
</form></td>
<tr>
<td height="35" width="177" valign="middle" align="center"></td>
<td height="232" width="674" valign="top" align="left" rowspan="2">
<form action="result.asp?chapterid=<%=chapterid%>&num=<%=num%>&order=<%=order(k)%>&j=<%=rs.recoderset%>" method=post name="form1">
<%i=1
rs.movefirst
Do While Not rs.Eof%>
<table border="1" width="95%" align="center" bordercolorlight="#000000" bordercolordark="#FFFFFF" cellspacing="0" cellpadding="5" bgcolor="#A4D1FF" height="81">
<tr>
<td bgcolor="#A4D1FF" height="1" width="100%" colspan="2">   <%=i%>、<%=rs("题目")%></td>
</tr>
<tr>
<td bgcolor="#D9E2F7" height="1" width="50%"><input name=ans<%=i%> type=radio value="A">
A.<%=rs("A")%></td>
<td bgcolor="#D9E2F7" height="1" width="50%"><input name=ans<%=i%> type=radio value="B">
B.<%=rs("B")%></td>
</tr>
<tr>
<td bgcolor="#D9E2F7" height="1" width="50%"><input name=ans<%=i%> type=radio value="C">
C.<%=rs("C")%> </td>
<td bgcolor="#D9E2F7" height="1" width="50%"><input name=ans<%=i%> type=radio value="D">
D.<%=rs("D")%> </td>
</tr>
</table>
<br>
<%i=i+1
rs.MoveNext
Loop%>
<p align=center>
<input id=submit1 name=submit1 type=submit value="提交">
<input id=reset1 name=reset1 type=reset value="重填">
</form></td>
</tr>
<%end if
else%>
<td height="13" width="688" valign="middle" align="center"> </td>
<tr>
<td height="35" width="177" valign="middle" align="center"> </td>
<td height="232" width="688" valign="top" align="center" rowspan="2">请 选 择 题 目 属 性!
<p><img border="0" src="image/tnpic029.jpg" width="129" height="80"></p></td>
</tr>
<%end if%>
<tr>
<td height="197" width="177" valign="top" align="center">
<form method="post" action="test.asp" name="test" onSubmit="return checkdata()">
<select size="1" name="chapter" class="td1">
<%
id=request("id")
if id<>"" then
sql="SELECT * FROM 教程 where 教程编号="&id&""
set rs=conn.execute(sql)
response.write "<option value='"&rs("教程编号")&"'>"&rs("章节")& rs("标题")
response.write "</option>"
else
response.write "<option value=''>请选择题目所属的章节</option>"
end if
Set rs1=Server.CreateObject("ADODB.RecordSet")
mySQL = "SELECT * FROM 教程 order by 教程编号"
rs1.Open mySQL,conn,1,1
Do While Not rs1.Eof
response.write "<option value='"&rs1("教程编号")&"'>"& rs1("章节") & rs1("标题")
response.write "</option>"
rs1.movenext
loop
response.write "<option value='all'>"&"全部题目"
response.write "</option>"%>
</select>
<p>题目数量  
<input type="text" name="num" size="4" class="td1" value="5" style="text-align: center;">
   题</p>
<p>
<input type="submit" value="开始答题" name="A1">
</p>
</form>
<p> 
</td>
</tr>
</table>
<!--#include file="config/copyright.asp"-->
</BODY>
...全文
1107 16 打赏 收藏 转发到动态 举报
写回复
用AI写文章
16 条回复
切换为时间正序
请发表友善的回复…
发表回复
stone_0_1 2005-03-26
  • 打赏
  • 举报
回复
老兄好!想要源代码,发给你!QQ31713391 找我!
lv_kevin 2005-03-26
  • 打赏
  • 举报
回复
你是不是少复制了end if
否则如果你原来的代码能用,改过后就应该没问题。
stone_0_1 2005-03-26
  • 打赏
  • 举报
回复
又出现问题了!
stone_0_1 2005-03-26
  • 打赏
  • 举报
回复
Microsoft VBScript 编译器错误 错误 '800a03f6'

缺少 'End'

/iisHelp/common/500-100.asp,行242

Microsoft VBScript 运行时错误 错误 '800a01b6'

对象不支持此属性或方法: 'recoderset'

/test.asp,行100
lv_kevin 2005-03-26
  • 打赏
  • 举报
回复

num=cint(trim(request.form("num")))
换成:

num=0
if isNumeric(trim(request.form("num"))) then
num=cint(trim(request.form("num")))
end if

就是了。
91jk 2005-03-26
  • 打赏
  • 举报
回复
...网上下的代码?

那数据库中就应该是数字型了~~

可能是你传值有错,不是数字型

最简单方法,将你文本框做下定义,只能输数字就行了
<input name="tb" id="tb" style="ime-mode:disabled" size="12" onpropertychange="if(!/^[\d\.]*$/.test(this.value))this.value=this.value.replace(/[^\d\.]/g,'')">

这是个例子,你试一下

不能全部定义成这样哦。。。
stone_0_1 2005-03-26
  • 打赏
  • 举报
回复
不好意思,这个网上下来的代码。能说的具体点吗?
91jk 2005-03-26
  • 打赏
  • 举报
回复
clnt在数据库中设置字段类型为数字型~~

另外你的传值也必须为数值型
Hotlion 2005-03-26
  • 打赏
  • 举报
回复
不用定义的,因为数据是从表单提交中来,因此只要保证两点:1、传递过来的值一定要是数值型的字符串,2、在接收表单数据的页面中将该数值型的字符串转换为数值型即可。从你的情况来看,首先要保证request.form("num")所包含的字符不能为除0~9以外的其它字符。
stone_0_1 2005-03-26
  • 打赏
  • 举报
回复
怎么把num定义成数字类型啊?开始的时候。
stone_0_1 2005-03-26
  • 打赏
  • 举报
回复
Microsoft VBScript 运行时错误 错误 '800a000d'

类型不匹配: 'Cint'

/test.asp,行48


stone_0_1 2005-03-26
  • 打赏
  • 举报
回复
本人初学者,能帮我解决一下吗?具体点怎么改?哈!还有怎么给分啊?
lv_kevin 2005-03-26
  • 打赏
  • 举报
回复
被转换的类型需要“看起来象数”才行
比如串"1212"
有不是数的字符就不OK,最好用isNumeric判断一下,而且记得用Trim销空格
德仔 2005-03-26
  • 打赏
  • 举报
回复
CInt 函数
返回表达式,此表达式已被转换为 Integer 子类型的 Variant。

CInt(expression)

expression 参数是任意有效的表达式。

说明
通常,可以使用子类型转换函数书写代码,以显示某些操作的结果应被表示为特定的数据类型,而不是默认类型。例如,在出现货币、单精度或双精度运算的情况下,使用 CInt 或 CLng 强制执行整数运算。

CInt 函数用于进行从其他数据类型到 Integer 子类型的国际公认的格式转换。例如对十进制分隔符(如千分符)的识别,可能取决于系统的区域设置。

如果 expression 在 Integer 子类型可接受的范围之外,则发生错误。

下面的示例利用 CInt 函数把值转换为 Integer:

Dim MyDouble, MyInt
MyDouble = 2345.5678 ' MyDouble 是 Double。
MyInt = CInt(MyDouble) ' MyInt 包含 2346。
注意 CInt 不同于 Fix 和 Int 函数删除数值的小数部分,而是采用四舍五入的方式。 当小数部分正好等于 0.5 时, CInt 总是将其四舍五入成最接近该数的偶数。例如, 0.5 四舍五入为 0, 以及 1.5 四舍五入为 2.



我的也没有错呀!楼主要给点分分呀
Hotlion 2005-03-26
  • 打赏
  • 举报
回复
cint的确是把字符转换为数值的函数。取整函数是int
德仔 2005-03-26
  • 打赏
  • 举报
回复
num=cint(trim(request.form("num")))
你要保证num 的值是数学才行,可以用IsNumeric 函数来做一下决断呀.

CInt 函数只是一个取整用的。

28,406

社区成员

发帖
与我相关
我的任务
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧