临时写的,有些地方不是很严谨,仅做参考
'参数说明:n表示产生的位数,yes_str表示要包含的数字,no_str表示不能包含的数字
function rnd35(n,yes_str,no_str)
randomize
str=""
if len(yes_str)>0 then
str=yes_str&","
end if
do while ubound(split(str,","))<n
tmp=int(35*rnd()+1)
if len(tmp)=1 then tmp="0"&tmp
if instr(str,tmp)<=0 then
str=str&tmp&","
end if
if instr(no_str,tmp)>0 then
str=replace(str,tmp&",","")
end if
tmp=""
loop
rnd35=str
end function
'调用示例
Response.Write(rnd35(7,"15,16,17","01,02,03,04,05,06,07,08,09"))
<SCRIPT LANGUAGE=vbscript >
'洗牌
Dim N,S,D,P
P=54'牌的数量
Set D = CreateObject("Scripting.Dictionary")
do while D.Count<P
Randomize
N=Int(P * Rnd + 1)
if not D.Exists(cstr(N)) then
D.Add cstr(N),cstr(N)
end if
loop
for each K in D.Keys
S=S & K & " "
next
msgbox replace(trim(S)," ",",")
</SCRIPT>
'数字生成
Function GenNumber()
Randomize
xrnd=Cint(RND*(iAll+1))
If xRnd>=1 And xRnd<=iAll Then
'如果不在必选的范围内,则继续
If Instr(1,sS1, "," & xRnd & ",",1)<=0 Then
'如果不在必不选的范围内,则继续
If Instr(1,sS2, "," & xRnd & ",",1)<=0 Then
'组合成已选字串
sS1=sS1 & xRnd & ","
iCount=iCount+1
If iCount>=iS1 Then
Exit Function
End If
End If
End If
End If
'递归
GenNumber
End Function
%>