主题:为什么随机生成的数字串会重复?
小弟想做个生成会员编号的系统,可用这段代码生成的数字串大都差不多,甚至重复。请问各位帮帮我怎么解决? 小弟在此谢过!
代码如下:
Code_nst = "1234567890"
Recode_nst = RoundStr(Code_nst,8)
Function RoundStr(str,Num)
s = ""
for i = 1 to Num
Randomize
strLen = Len(str)
t = Round((Rnd * (strLen-1))+1)
s = s & mid(str,t,1)
Next
RoundStr = s
End Function
我试了10次 生成的数字如下 :
937197
472542
936097
826986
826986
583653
947198
047208
937097
472542
代码如下:
Code_nst = "1234567890"
Recode_nst = RoundStr(Code_nst,8)
Function RoundStr(str,Num)
s = ""
for i = 1 to Num
Randomize
strLen = Len(str)
t = Round((Rnd * (strLen-1))+1)
s = s & mid(str,t,1)
Next
RoundStr = s
End Function
我试了10次 生成的数字如下 :
937197
472542
936097
826986
826986
583653
947198
047208
937097
472542