关键词
ASP 随机数
摘要
本文介绍使用ASP来生成两个数字之间的随机数,比如生成50到100之间的随机数。
本文介绍使用ASP来生成两个数字之间的随机数,比如生成50到100之间的随机数。
突然有这样一个需求:要用ASP来生成一个50到100之间的随机数。简单的写了一个程序,留在这里,以后方便直接Copy。
Function GetRndBetweenTwoNums(numSmall, numLarge) Dim tmp Randomize tmp = Fix(numSmall + Rnd() * (numLarge - numSmall)) GetRndBetweenTwoNums = tmp End Function
调用一下,
<%
Response.Write GetRndBetweenTwoNums(50, 100)
%>
多试几次,每次生成的结果均是50到100之间。