可用的ASP无重复数字随机函数, 数组实现, 并应用(2)
' dim t
' for each t in fRndNoRpt(1,100)
' response.write t&"<br/>"
' next
''''''''''''''''''''''''''''''''''''''''''''
if upNum<1 or isNull(upNum) or upNum="" or isNumeric(upNum)=false then exit function
if lwNum<0 or isNumeric(lwNum)=false then exit function
dim num, temp
dim ar()
redim ar(upNum)
dim j:j=0
for temp=lwNum to upNum
num=num&"."&temp&"."
next
randomize
do until num=""
temp=int((upNum-lwNum+1)*rnd+lwNum)
if inStr(num,"."&temp&".")<>0 then
num=replace(num,"."&temp&".","")
ar(j)=temp
j=j+1
end if
loop
fRndNoRpt=ar
erase ar
end function 'shawl.qiu code'
response.write "<p/>使用随机数函数显示1至100的不重复随机数 1:<br/>-----------------------<br/>"
for each temp in fRndNoRpt(1,100)
response.write temp&"<br/>"
内容版权声明:除非注明,否则皆为本站原创文章。