Dim i,j
j = GetRndNotRepeat( 1, 10, 10)
If j(0), then
For i = 1 to 10.
MsgBox(j(i))
then
If ... it will be over.
End joint
The public function GetRndNotRepeat(ByVal NumMin is an integer, ByVal NumMax is an integer, and ByVal n is an integer).
Compile: xsfhlzh
Function: take n random integers between NumMin and NumMax.
Description: the array of flags is Byte, and each bit represents the state of a certain number between NumMin and NumMax.
Dim arr () is an integer.
If n & gtNumMax-NumMin+1 then
ReDim arr(0)
arr(0) = 0
Return to arr
other
ReDim arr(n)
Mark m as an integer
Dim b () is a byte.
m = Int((NumMax - NumMin) / 8)
Redim b(m)
Entrance sign
Dim i
Mark x, y and z as integers.
Randomization ()
arr(0) = 1
For i = 1 to n
do
Find the position of x, where y indicates which byte x is in the array and z indicates which byte x is in.
x = Int(Rnd()*(NumMax-NumMin+ 1))+NumMin
y = x - NumMin
z = 2 ^ (y Mod 8)
y = y \ 8
B(y) and z-time cycle
B(y) = b(y) or z
arr(i) = x
Find the uncapped number, put it into the array, and set the flag bit.
Next, I
If ... it will be over.
Return to arr
End function