The VBScript Rnd function uses a 24-bit Linear Congruential Generator. The constants involved were determined as follows:

  1. First, it was assumed that a 24-bit Linear Congruential Generator is used. The intermediate results in such a generator can be represented exactly in VBScript. Also, documentation on the Microsoft web site implies that a 24-bit generator is used. Such a generator is in the form:

    Xi = [(A * Xi-1) + C] Mod M
    where M = 2^24 = 16,777,216

  2. It is assumed that if a value of zero is passed to the Randomize function, the seed for the Linear Congruential Generator, Xi-1, becomes zero. The first value returned by the Rnd function is then 0.7641413. Multiplying this normalized value by the modulus, 2^24, results in 12,820,163.

  3. The constant C can them be calculated as follows:

    12820163 = [(A * 0) + C] Mod 2^24
    C = 12820163

  4. The next value returned by the Rnd function is 0.3756428. Multiplying this normalized value by 2^24 results in 6,000,250. Then:

    6000250 = [(A * 12820163) + 12820163] Mod 2^24

The only way I can see to solve this for A is by trial and error. Fortunately, this is reasonable to do in a program. It involves trying all 16,777,216 possible values for A. Doing this confirms that there is only one value for A that satisfies the equation above, which is A = 16,598,013.

It is straightforward to verify that the resulting Linear Congruential Generator can be used to duplicate the values returned by the Rnd function. However, no way has been found to determine how the Randomize function seeds the Linear Congruential Generator used by the Rnd function. In retrospect, it is lucky that passing a value of zero to Randomize results in a seed value of zero.