随机函数的问题

yunshiyu 2003-06-13 06:11:06
<%@ language = vbscript %>
<%
Set conn = Server.CreateObject("ADODB.Connection")
conn.Open "driver={Microsoft Access Driver (*.mdb)};dbq=" & Server.MapPath("../考试系统.mdb")
set rs= server.createobject("adodb.recordset")
sql="select * from 填空题表 where 难易程度 = 'a'"
set base=conn.execute(sql)
dim a(1000)
j=0
do while not base.eof
th=base("题号")
a(j)=th
j=j+1
base.movenext
loop
Randomize
for m = 0 to 4
Randomize
i=Int((j*rnd)+1)
response.write i&"<BR>"
next
%>
本想生成5个不同的数,但每次都没成功,该如何实现这个功能?
...全文
29 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
summercat 2003-06-13
  • 打赏
  • 举报
回复
身份证号丢了那人的..昨天刚收藏
<SCRIPT LANGUAGE=vbscript>
<!--

Dim i,num,ary(4),str

str =""
Randomize()


for i = 0 to 4

num = (100*rnd) mod 23
do while numInAry(num,ary)
num = (100*rnd) mod 23
loop
ary(i) = num
str = str & num & ","
next

str = left(str,len(str)-1)
alert(str)



function numInAry(num,ary)
Dim i
for i = lbound(ary) to Ubound(ary)
if num = ary(i) then
numInAry = true
exit function
end if
next
numInAry = false

End function

28,390

社区成员

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

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