'生成任意位随机数的函数
'strLong是随机数字的位数,数字型
Function rndNum (strLong)
Dim temNum
Randomize
Do While Len(RndNum) < strLong
temNum=CStr(Chr((57-48)*rnd+48))
RndNum=RndNum&temNum
loop
End Function
'strLong是随机数字的位数,数字型
Function rndNum (strLong)
Dim temNum
Randomize
Do While Len(RndNum) < strLong
temNum=CStr(Chr((57-48)*rnd+48))
RndNum=RndNum&temNum
loop
End Function
博客展示了一个生成任意位随机数的函数。该函数名为rndNum,接收一个表示随机数字位数的数字型参数strLong,通过循环和随机数生成逻辑,最终生成指定位数的随机数。
797

被折叠的 条评论
为什么被折叠?



