[Solved]Random number help
I created two different random numbers but both of them always generate the same number, and I don't know whats going on, any help would be appreciated. My VB teacher at school helped me with this but I forgot what he did.
make sure the 1st number is SMALLER than the 2nd number by at least two.
2 things,
One is, What are you talking about Mneep?
Second,
Problem with VB is when you generate a random number, you are generating Psuedo Random, Meaning both numbers will be the same, and both numbers will generate the same numbers from start to finish, no real random
To avoid this
part one :
Each number should have different Values
Rnd(1) * 4 + 1
Rnd(1) * 4 + 2
The pplus at the end will change the values and make them different, Now how to prvent the Psuedo Random outcome is alittle more tricky,
One way is to use a label that is attached to a timer,
Timer1 event
Label1.text = label1.text + 1
then you call your random numbers elsewhere
rnd(1) * 5 + label1.text
rnd(1) * 4 + Label1.text
or (and my favorite) is to generate a number based off your current system.diagnostics
Cpu speed, that number is always fluctuating allowing more random numbers
Hope this helps
Here is another solution:
Dim x As New Random
'Generates a random number between 1 to 100
x.Next(1, 100)
Hope this helps !!