|
-
Jan 10th, 2010, 10:17 AM
#1
Thread Starter
New Member
Simple math problem! Newbee
Hello guys, I hope you can help me with this little problem.
Basically, I want to divide two numbers together and they should be 2 random numbers from 1-12 (I have done that part) but, the answer should be a whole number (i.e. Integer, so no decimal points etc)
So, I did the following:
' Initialize the random-number generator.
Randomize()
' Generate random value between 1 and 12.
Dim value5 As Integer = CInt(Int((12 * Rnd()) + 1))
Label3.Text = value5
' Generate random value between 1 and 12.
Dim value6 As Integer = CInt(Int((12 * Rnd()) + 1))
Label4.Text = value6
'make sure its only whole numbers when dividing
If Int(value5 / value6) = False Then
Do Until Int(value5 / value6) = True
Loop
but the problem here is that the program crashes after only a few clicks on the button.
So I guess the question is: How can I make the program generate two numbers (from 1-12) that when divided become a whole number?
(Is there any code that may tell the random generator that I want the numbers to be even?-so all even numbers from 1-12?)
Thanks!
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
|