A simpler version, to the ticks
Per ForumAccount's suggestion in post#7, I've change the loop to test just if NextDouble > 0 since the return value is alreay always < 1.Code:Private rng As New Random Private Function PickRandomDateBetween(ByVal fromDate As Date, ByVal toDate As Date) As Date Dim multiplier As Double = rng.NextDouble Do Until (multiplier > 0.0R) multiplier = rng.NextDouble Loop Return fromDate.AddTicks(CLng(multiplier * toDate.Subtract(fromDate).Ticks)) End Function
I also changed the literal type character from D to R (for some reason, I keep mixing those up)




)
Reply With Quote
