Randomize 是随机初始化,使用rnd之前必须要先来一句Randomize
rnd-随机函数,用于随机,为了防止重复,你可以用一个数组(如果是用来随机整数,开Bool数组,随机实数九要开实数数组)来保存已经随机出来的结果,每随机一个判断一下是否随机过,具体实现方法,要看你的数据类型了,- <%
- session("jl")=""
- a1=setnum()
- a2=setnum()
- a3=setnum()
- a4=setnum()
- a5=setnum()
- a6=setnum()
- a7=setnum()
- a8=setnum()
- response.Write(a1 & "
- ")
- response.Write(a2 & "
- ")
- response.Write(a3 & "
- ")
- response.Write(a4 & "
- ")
- response.Write(a5 & "
- ")
- response.Write(a6 & "
- ")
- response.Write(a7 & "
- ")
- response.Write(a8 & "
- ")
- function setnum()
- Randomize
- jlsz=split(session("jl"),";")
- cfbj=2
- while cfbj=2
- setnum=int(rnd()*50)
- for i=0 to Ubound(jlsz)-1
- cf=0
- if cint(setnum)=cint(jlsz(i)) then
- cf=1
- exit for
- end if
- next
- if cf=0 then
- cfbj=0
- else
- cfbj=2
- end if
- wend
- session("jl")=session("jl")& setnum &";"
- end function
- %>
复制代码 |