 | | Home | | FAQ | | Support | | Download | | Register | | Affiliates | |
VBA Functions
|
ZRandom can also be used from your VBA projects, just add a reference to
"ZRandom" and use ZRandom.Next and ZRandom.NextBetween to generate random
numbers, or use one of the functions to generate random variables from a
probability distribution like NextPareto or NextHypergeometric.
|
Public Sub ShowRunningTotal()
' Re-seed ZRandom with the current time
ZRandom.Seed Timer
' generate 100 poisson numbers and keep a running total
Dim runningTotal As Double
Dim counter As Integer
For counter = 1 To 100
runningTotal = runningTotal + ZRandom.NextPoisson(5)
Next
' show the total
MsgBox "The total was: " & CStr(runningTotal)
End Sub
|
|