随机产生数的问题

b4ys 2004-01-14 03:14:39
我现在需要每次用户在申请帐号时我要随机产生一个5位数以上的号码,而且每次不能有重复,请问我该怎么写语句啊???
...全文
58 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
超级大笨狼 2004-01-14
  • 打赏
  • 举报
回复

<script language=vbs>
'功能:从很多字串中排除相同字串
'输入:很多字串组成的数组:
dim A,B
A=array("字串1","字串2","字串3","字串1","字串2","字串1","字串4")
'输出:
B=F(A)
'显示结果:B=array("字串1","字串2","字串3","字串4")
for each bbb in B
document.write bbb & "<br/>"
next

'函数部分
function F(x)'这里x是形参
dim S,D
Set D = CreateObject("Scripting.Dictionary")
for each xxx in x
if not d.Exists(xxx) then D.Add xxx,xxx
next
for each key in D.Keys
S=S & key & " "
next
set D=nothing
F=split(trim(S))
end function
</script>


超级大笨狼 2004-01-14
  • 打赏
  • 举报
回复


洗牌完美版:
<SCRIPT LANGUAGE=vbscript >
function xipai(mystr)
xipai=""
if len(mystr)=0 then'如果是空的,那么初试化一付连续的牌
for i=1 to 52
mystr=mystr & "<" & i & "> "
next
end if
dim i,x
for i=1 to 52
myarry=split(mystr) 'myarry是下标52的数组,前0-51个有效
randomize
x=cint(rnd*(ubound(myarry)-1))'前0-51个随便找一个
mystr=replace(mystr, myarry(x) & space(1),"")'从没发的牌中随便挑一张
xipai=xipai & myarry(x) & space(1)
next
end function

function XP(n)
mystr="xipai("""")"
dim i
for i=1 to n
mystr="xipai(" & mystr & ")"
next
XP=eval(mystr)
end function
document.write "洗牌完美版" & "<br/>"
document.write "洗一次牌:" & XP(1) & "<br/>"
document.write "洗两次牌:" & XP(2) & "<br/>"
document.write "洗三次牌:" & XP(3) & "<br/>"
document.write "洗一百次牌:" & XP(100) & "<br/>"
</SCRIPT>



紫郢剑侠 2004-01-14
  • 打赏
  • 举报
回复
/*
功能:生成5位的随机验证码
作者:Purple Endurer
输入:(null)
输出:(null)

Date Log
-------------------------------
01-14-2004 Created and Passed.
*/
function GetVerifyCode()
{
var VeriCode = 0;

while (VeriCode==1 || VeriCode==0)
{
VeriCode = Math.random();
}

VeriCode = String(VeriCode);
iVCodeLen = VeriCode.length;
return VeriCode = VeriCode.substring(iVCodeLen - 5, iVCodeLen);
}
b4ys 2004-01-14
  • 打赏
  • 举报
回复
谢谢各位了,我已经搞定了
b4ys 2004-01-14
  • 打赏
  • 举报
回复
我用的是ASP语句,请高手们帮帮我吧!
robinzo 2004-01-14
  • 打赏
  • 举报
回复
为什么要使用随机数啊
Jaron 2004-01-14
  • 打赏
  • 举报
回复
str = makepassword(5)
Function makePassword(maxLen) As String '生成随机密码
Dim strNewPass
Dim whatsNext, upper, lower, intCounter
Randomize
For intCounter = 1 To maxLen
whatsNext = Int((1 - 0 + 1) * Rnd + 0)
If whatsNext = 0 Then
'character
upper = 90
lower = 65
Else
upper = 57
lower = 48
End If
strNewPass = strNewPass & Chr(Int((upper - lower + 1) * Rnd + lower))
Next
makePassword = strNewPass
End Function

28,407

社区成员

发帖
与我相关
我的任务
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧