代码示例:
'--------------------
'-生成随机数
function rndarray(istart,iend,sum)
dim arrayid(),i,j,blnre,temp,iloop,eloop
redim arrayid(sum-1)
i=0
iloop=0
eloop=0
blnre=false
randomize
do while i
temp=int(rnd*(iend-istart+1)+istart)
if i=0 then
arrayid(0)=temp
i=i+1
iloop=iloop+1
else
for j=0 to i-1
if arrayid(j)=temp then
blnre=true
iloop=iloop+1
exit for '防止多余的循环
else
iloop=iloop+1
end if
next
if blnre=false then
arrayid(i)=temp
i=i+1
else
blnre=false
end if
end if
loop
rndarray=join(arrayid)
end function
response.write rndarray(1,5,1) '开始数字,结尾数字,生成多少个
%>