asp定义动态数组

来源:百度知道 编辑:UC知道 时间:2024/05/17 03:23:17
请大家看下我下面标记的部分,我的意思是从题库中找出单选题,把它的id放在数组 danxuan()中,由于不知道有几道题,就想找一道,题量dxtl+1,然后重定义数组,把id放进去。如果下面的不行,该怎么办呢?
i=1
dxtl=0
mxtl=0
dim danxuan()

dbrs.movefirst
do while not dbrs.eof
temp=dbrs("leixing")
select case temp
case "单选"
dxtl=dxtl+1
redim preserve danxuan(dxtl)‘这样定义对吗?我在浏览器预览时,
danxuan(dxtl)=dbrs("id") 'cpu都100%了

end select
i=i+1
dbrs.movenext
loop

dim danxuan
rs.open "select count(id) as num,leixing……",conn,1,1
redim danxuan(rs("num"))
for i=0 to rs("num")-1
select case temp
case "单选"
danxuan(i)=rs("id")
end select
rs.movenext
next
……

你在循环里面重定义怎么行呢?在do while 循环之前就重定义,根据获取到的记录总数来定义。