LegendaryAman LegendaryAman - 9 months ago 38
Vb.net Question

Generate random numbers with loop in interval VB.NET

How to generate random number loop in interval between 0-99 in title bar like this: https://www.dropbox.com/s/n6cvxlpjzklys80/vb.gif

I am able to generate random numbers in menu bar but unable to loop them in specific interval.

Dim value As Integer = CInt(Int((99 * Rnd()) + 1))
Dim randomnumber As String = "My random no. between " & value.ToString

Private Sub Form3_Load(sender As Object, e As EventArgs) Handles MyBase.Load

Me.Text = randomnumber

End Sub


Add a windows forms timer to your project and this code

Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
    Me.Timer1.Interval = 100 '10 per second
End Sub

Private Shared prng As New Random
Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick
    Me.Text = "My random no. between " & prng.Next(100)
End Sub