' Declare at form level
Dim objRandom As New System.Random( _
CType(System.DateTime.Now.Ticks Mod System.Int32.MaxValue, Integer))
Public Function GetRandomNumber( _
Optional ByVal Low As Integer = 1, _
Optional ByVal High As Integer = 100) As Integer
' Returns a random number,
' between the optional Low and High parameters
Return objRandom.Next(Low, High + 1)
End Function
' Using the above function to generate Random numbers.
Dim intDiceRoll As Integer
intDiceRoll = GetRandomNumber(1, 1000000)
MessageBox.Show("You rolled a " & intDiceRoll.ToString)
Pgmer 50 Master Poster Featured Poster
Pgmer 50 Master Poster Featured Poster
Pgmer 50 Master Poster Featured Poster