كود PHP:
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
وطريقة استدعائها هي كالتالي :
كود PHP:
Dim MyRand As Integer
MyRand = GetRandomNumber(1, 6)
MessageBox.Show("Your Random Number Is " & MyRand.ToString)