## myBlog |

View Count: 106

Keywords: random, function, vb.net

i was trying to randomly walk a 156GB database and randomly go through millions and millions of records, so I decided to see if you this randomness function would work without salting the rnd generator, it worked... , given an upper bound, my upper bound row id was 1526763840.. so try this..

'check randomness function

Debug.Print("randomness function test")

Dim r

Dim x

For x = 1 To 1000

r = CInt(Math.Ceiling(Rnd() * 1526763840) + 1)

Debug.Print(x & vbTab & r)

Next

Debug.Print("randomness function test")

Dim r

Dim x

For x = 1 To 1000

r = CInt(Math.Ceiling(Rnd() * 1526763840) + 1)

Debug.Print(x & vbTab & r)

Next

correction: use this in place of the r = line above

'r = CInt(Math.Ceiling(Rnd() * maxDBrecords) + 1)

Static Generator As System.Random = New System.Random()

r = Generator.Next(1, maxDBrecords)

'as long as r is within bounds

Static Generator As System.Random = New System.Random()

r = Generator.Next(1, maxDBrecords)

'as long as r is within bounds

more to come.

© 2020 myBlog™ v1.1 All rights reserved. We count views as reads, so let's not over think it.