任何写ASP随机而用不重复数字的函数呢?下面这个函数应该是可以。大家可以那去用用看。看是否成功! <script language="vbscript"> |
Function GetrndNumber(intStart,intEnd,intCount)
Rem 取指定范围内不同的随机整数
Rem intStart:起始值
Rem intEnd:结束值
Rem intCount:值个数
Rem no_mIss
Rem 调用:GetrndNumber(1,9,5)
On error resume next
Dim i,reValue,strreValue
reValue = "" : strreValue = ","
If Not isNumeric(intStart) or Not isNumeric(intEnd) _
or Not isNumeric(intCount) Then Response.write "参数错误!" : Response.End
If intCount>(intEnd - intStart)+1 Then Response.write "参数错误!" : Response.End
randomize
For i = 0 to intCount - 1
reValue = Int((intEnd - intStart + 1) * Rnd + intStart)
If instr(strreValue,"," & reValue & ",")>0 Then
i = i - 1
Else
strreValue = strreValue & reValue & ","
End If
Next
strreValue = left(strreValue,len(strreValue) - 1)
strreValue = Replace(strreValue,",","",1,1)
GetrndNumber = strreValue
End Function
</script>