Hi!
To cut to the chase, when I want to create four random numbers they are all the same. (I do not want that.) Is this because I have 4 random numbers being generated almost at the same time; do they use the same random seed even though I declare R as NEW random?
By the way - this is just a test code but my real program does the same thing. Thanks for the help in advance!
vb Code:
Public Class Form1 Dim TestString As String = "" Private Sub Timer1_Tick(sender As System.Object, e As System.EventArgs) Handles Timer1.Tick Timer1.Stop() A() B() C() D() Label1.Text = TestString TestString = "" End Sub Private Sub A() Dim R As New Random Dim A As Int32 = CInt(R.Next(0, 100)) TestString += A.ToString & ", " End Sub Private Sub B() Dim R As New Random Dim B As Int32 = CInt(R.Next(0, 100)) TestString += B.ToString & ", " End Sub Private Sub C() Dim R As New Random Dim C As Int32 = CInt(R.Next(0, 100)) TestString += C.ToString & ", " End Sub Private Sub D() Dim R As New Random Dim D As Int32 = CInt(R.Next(0, 100)) TestString += D.ToString End Sub Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click Timer1.Start() End Sub End Class




Reply With Quote
