|
-
Jan 10th, 2000, 02:49 AM
#1
Thread Starter
Hyperactive Member
Hi,
I'm making a program that will need to randomize two numbers. The problem is that the numbers are not close to each other like 1 to 2. The numbers are something like 2 to 6. But you understand, I only want to random one of those two numbers. If I said:
intNumber = int((6 * RND) + 1)
I would get all the numbers in between aswell. I hope you understande what I'm saying here. I only want to random 2 or 6 using the random function. Could you please help?
Thank you!
-
Jan 10th, 2000, 02:53 AM
#2
Hyperactive Member
would this work for you?
If int((6 * RND) + 1)<3 then
intNumber = 2
Else
intNumber = 6
End If
-
Jan 10th, 2000, 03:21 AM
#3
Thread Starter
Hyperactive Member
Hi badgers,
Maybe I should have been a little more clear in my question. I just used 2 and 6 as an example. Really I want to randondomize one of the numbers 2 3 5 7 and 9. So I'm not too sure that way would work. I will be happy to hear any other ways you may know.
Thanks
-
Jan 10th, 2000, 03:39 AM
#4
I think we are having a problem understanding what you mean by "randomize one of the numbers". Can you give an example of the results you would expect?
------------------
Marty
-
Jan 10th, 2000, 03:57 AM
#5
New Member
just do like badgers said, but split the resulst into 5 parts
intNumber = int((5 * RND) + 1)
then:
if intNumber = 1 then Result = 2
if intNumber = 2 then Result = 3
if intNumber = 3 then Result = 5
if intNumber = 4 then Result = 7
if intNumber = 5 then Result = 9
(a case statement would be easier though)
-
Jan 10th, 2000, 03:58 AM
#6
Fanatic Member
or use this:
Code:
Dim Done As Boolean
Dim myNum As Integer
Do While Not Done
myNum = Int((9 * Rnd) + 1)
If myNum <> 2 And myNum <> 3 And myNum <> 5 And myNum <> 7 And myNum <> 9 Then
Done = False
Else
Done = True
End If
Loop
------------------
Visual Basic Programmer
------------------
PolComSoft
You will hear a lot about it.
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
|