Random Number Question

J

John Viall

I am trying to generate a random number by seeding randomizer with the date
and time. I need to be able to verify that the seed and random number
generated are correctly matched. But even with the same seed value typed in,
I'm still getting random numbers. Is there a way to do this in VBA? My
understanding of seeding is that given the same seed value, the pattern
should hold true. Am I missing something here?

Public Sub AutoExec()
Dim seed As Date

seed = Now
Randomize (39543) 'I have changed this number to seed when running off time.

'Generate a random number.
'Rand is a function that works like: Rand (lowest number, highest number)
ActiveDocument.FormFields("txtSeed").Result = seed
ActiveDocument.FormFields("txtCode").Result = Rand(1, 1000000)
End Sub
 
J

John Viall

I also just noticed that this doesn't work with the Sub Autoexec. Any other
suggestions?
 
Top