This is the first time i'm using VB and was wondering how i can randomly generate numbers from 1-5. is it just:
dim x as integer=Rnd(4)+1
??
also, do i import anything for the Rnd method to work? Or create some sort of function?
Printable View
This is the first time i'm using VB and was wondering how i can randomly generate numbers from 1-5. is it just:
dim x as integer=Rnd(4)+1
??
also, do i import anything for the Rnd method to work? Or create some sort of function?
Welcome to the forums.
Recommend adding this line in your form's load event: Randomize Timer
That call will use the system timer value (changes each millisecond) to seed the random number generator. You can seed the generator with any number you choose
A formula to retrieve a random number in a range of 1 to Max is
X = Int(Rnd * [max number]) + 1