Access/VBA Library

Rand Method

Picks one or more random entries out of an array.

Syntax

array_.Rand( [Count] )
Parameters
Name Type Description
array_   The name of an object of type array_
Count Integer Optional. Number of random elements to be picked.
Default: 1

Remarks

  • When count is greater than 1 elements may be picked a couple of times.
Example
  Dim x As New Array_
  Dim randomArray As Array_

  x.FromArray (Array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10))
  Set randomArray = x.Rand(3)
  'Result could be:
  'Array (
  ' [1] = > 6
  ' [2] = > 2
  ' [3] = > 2
  ')