Public Class TrueRandom2
    Public Function GetDouble() As Double
        Dim r As New Security.Cryptography.RNGCryptoServiceProvider

        Dim bt(15) As Byte
        r.GetNonZeroBytes(bt)
        Dim d As Double = bt(0)
        For i As Integer = 1 To 15
            d *= bt(i)
        Next
        d /= (10 ^ (Math.Floor(d).ToString.Length))
        d -= Math.Floor(d)
        Return d
    End Function
    Public Function GetNext(ByVal lower As Integer, ByVal upper As Integer) As Integer
        'returns a random itneger between specified bounds
        'ratio a random decimal number to the required bounds
        Return CInt(lower + (GetDouble() * (upper - lower)))
    End Function
    Public Function GetNext() As Integer
        'returns a random integer
        Return CInt(GetDouble() * Integer.MaxValue)
    End Function
    Public Function GetLong() As Long
        Return CLng(GetDouble() * Long.MaxValue)
    End Function
End Class
