Build a random generated data string.
Written by Kenneth Ives   kenaso@home.com

For use with Visual Basic 5 or above because of the Enum
functions.

Use this BAS module as a guideline.  Your imagination is your 
only limitation.

From Microsoft's MSDN: 
     Randomize uses a number to initialize the Rnd function's
     random-number generator, giving it a new seed value. If
     you omit number, the value returned by the system timer
     is used as the new seed value.
     
     If Randomize is not used, the Rnd function (with no 
     arguments) uses the same number as a seed the first time 
     it is called, and thereafter uses the last generated 
     number as a seed value.

     Note:   To repeat sequences of random numbers, call Rnd 
     with a negative argument immediately before using 
     Randomize with a numeric argument. Using Randomize with 
     the same value for number does not repeat the previous 
     sequence.  
     
             Example:      Rnd -1
                           Randomize 1

This approach may be fine for game programming but 
sometimes we use random generation for creating truely 
random values either as a filler for something or security.

When you use Randomize by itself, the default is to use the
TIMER.  TIMER is the system date and time stamp returned as
a single precision number unique at that particular time.
This is a very good starting point for most of us; however,
you should always use a truely unique number for seeding 
the random number generator prior to generating the new 
values.



There are two routines in my BAS module.  Be sure to read all
the documentation within the code.

----------------------------------------------------------------
Sub Seed_Random_Generator()  

One is to seed the random generator with a unique seed.  This
can be called by itself without having to build a data string.
I build a seed that is a 64-bit (8 byte) floating point number.
Randomize will return a 32-bit (4 byte) floating point number.
Now, each time you use the RND function, a unique value will be 
returned.  You can re-seed as often as you want.  This is
my algorithym for creating a unique number.  Modify as you see
fit.

  1.  Execute "Randomize Timer" to initialize the generator
  2.  Capture the number of milliseconds since the last reboot
  3.  Get the value of the current date/time stamp
  4.  Calcualte the value of Pi to 14 decimal places
  5.  Accumulate the total of all active windows & sub window
      handles 
  6.  Get the volume serial number of drive C: 
  7.  Calculate the square root of the running total thus far
  8.  Random generated value from Pi
  9.  Random generated value from the system timestamp
 10.  Random generated value from step 2 (Tick count)
 11.  Random generated value from the value of one
 12.  Random generated value from the value in step 5
 13.  Random generated value from the value in step 6
 14.  Add all of these together for the new seed
 
 
----------------------------------------------------------------
Function Build_Random_Data(lDataLength As Long, _
               Optional bAllChars As Boolean = True) As String
                
The is where I build a data string of random generated 
values based on two inputs furnished by the user.  The first
is the length of the data string and the other is whether 
or not to use all the ASCII values of 0-255 (Default) or just 
the printable values of 32-126.  Each time this function is 
called, the subroutine Seed_Random_Generator is also called.


----------------------------------------------------------------
There is a test routine named "xMain".  Load this BAS module
by itself into Visual Basic 5 or above.  Rename it to "Main" 
and press the F5 key to execute.  Look in the debug immediate
window for the results.


