VB NOTES PART 11 - () Returns a random integer between 0...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
3/3 ---Random Numbers First: no such thing as a computer-generated random number (computers can’t do random) Pseudo-random numbers---very close to random--result of some complex math function ---Algorithm Take large number (constant) multiply by another large number (seed) Mod some third large number (constant) For2nd number, multiply & mod again ---Random object Dim randomObject As Random = New Random () Reference variable call to constructor refers to an object Dim randInt As Integer = randomObject. Next
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: () Returns a random integer between 0 and 2^32-1 randInt = randomObject. Next (37) Between 0 and 36 randInt = randomObject. Next (3, 37) Between 3 and 36 randLint = randomObject. Next(0, 5) -2 Between -2 and 2 Dim randDbl As Double = randomObject. NextDouble () Returns Double between 0.0 and 1.0, but never 1.0 (0 is possible but never 1)---[0,1) Rand Dbl = randomObject. Next Double () *4-2 Between -2 and 2...
View Full Document

This note was uploaded on 12/01/2011 for the course 6K 226 taught by Professor Staff during the Fall '10 term at University of Iowa.

Ask a homework question - tutors are online