|
-
Apr 4th, 2008, 12:47 PM
#1
Thread Starter
New Member
Random number
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?
-
Apr 4th, 2008, 12:52 PM
#2
Re: Random number
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
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|