ASP中一个用VBScript写的随机数类

外国人写的一个class,这么一点小小的应用,除非有特殊需求,还没有必要模块化。
用asp产生一个随机数。
<% 
''************************************************************************** 
'' CLASS: cRandom 
'' Calls randomize to seed the random number generator. 
'' Provides functions for returning ranged random integers or arrays of 
'' ranged random integers. 
'' Calling randomize to seed the random number generator at the time the 
'' class is created seemed like a reasonable thing to do. 
private sub Class_Initialize() 
'' Check the VBScript documentation for the specifics relating 
'' to the Randomize function 
Randomize 
end sub 
'' Terminate doesn''t need to do anything for this class 
private sub Class_Terminate() 
end sub 
''********************************************************************** 
'' FUNCTION: RangedRandom 
'' PARAMETER: lowerBound, the lowest allowable number to return 
'' PARAMETER: upperBound, the highest allowable number to return 
'' RETURNS: A random integer between lowerBound and UpperBound, 
'' inclusive 
''********************************************************************** 
public function RangedRandom( lowerBound, upperBound ) 
RangedRandom = CInt((upperBound - lowerBound) * Rnd + lowerBound) 
end function 
''********************************************************************** 
'' FUNCTION: RangedRandomArray 
'' PARAMETER: lowerBound, the lowest allowable number to return 
'' PARAMETER: upperBound, the highest allowable number to return 
'' PARAMETER: arraySize, zero based number specifying the size of the array 
'' PARAMETER: duplicates, true or false to indicate whether duplicate 
'' resize the tempArray to hold the number of elements passed in the 
'' arraySize parameter 
redim tempArray(arraySize) 
'' This is a loop counter, set it to 0 
filledElements = 0 

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:http://www.heiqu.com/3579.html